Server Routing

From Braindisconnect
Jump to navigationJump to search


When we think of routing, we almost always think of routers on the network. The network does do routing, however almost all devices that interact with Layer 3 of the OSI Layer Model perform fundamental routing. Even if the device only has one NIC it is still performing routing functions.

Servers are pretty easy to configure for routing when they only have have one NIC, but adding another NIC to a server will complicate the network configuration on the server.

Important Points

There can only be one NIC per subnet or VLAN, unless Link Aggregation is being configured. There is one more exception, but involves setting up detailed routing tables for the subnet and the interfaces.

There can only be one default gateway.


SuSE

In SuSE, there are two ways to set up persistent routes. You can either add routes to the a file called route or a route file based on the interface. It doesn't matter since the network services script will read both files. It is usually easier to maintain the main route file then keeping track of each interface routing table. Either way, the result is the same.

Adding routes to the route file

The route file is located in the /etc/sysconfig/network/ directory.

/etc/sysconfig/network/routes

The basic syntax:

Destination Mask    Gateway Mask     Interface

An example for static CorpNet:

10.3.72.0 255.255.252.0      0.0.0.0 0.0.0.0     eth0
0.0.0.0 0.0.0.0              10.3.72.1           eth0
10.120.2.0 255.255.255.0     0.0.0.0 0.0.0.0     eth1
10.120.0.0/17                10.120.2.1          eth1    

An example for DHCP CorpNet:

default 10.3.72.1 - -
10.120.2.0 255.255.255.0     0.0.0.0 0.0.0.0     eth1
10.120.0.0/17                10.120.2.1          eth1    

The first line sets up the network for eth0.
The second line sets up the default route, meaning if there is no route defined, then it sends it out eth0 to 10.3.72.1.
The third line sets up the network for eth1.
The fourth line sets up the main route for the Cisco lab.

Red Hat Enterprise

You will need to edit the route file for the NIC. route-ethX where X = the NIC.

You can also echo it into the file.

Example:

echo '10.120.0.0/17 via 10.120.17.1' >> /etc/sysconfig/network-scripts/route-eth1

You will need to bounce the interface or reboot the server/VM for the route to take effect.

Windows XP, Vista, and 7

For a temporary route that will go away on the next reboot:

route add 192.168.5.0 mask 255.255.255.0 172.16.18.5

For a persistent route, simply add a /p at the end of the command

route add 192.168.5.0 mask 255.255.255.0 172.16.18.5 /p