User Tools

Site Tools


info:routes

Note that for a route to work, each endpoint needs to have a route to the other.

These examples show adding a route to a simple subnet that exists on the same network segment as the local machine (e.g. connected by a switch).

Routes in Linux (change interface name as needed)

sudo route add -net 172.16.4.0 netmask 255.255.255.0 dev eth0
sudo route add -net 172.16.5.0 netmask 255.255.255.0 dev eth0
netstat -rn # to list routes

Making Persistent (Red Hat)

Manual

To make persistent (http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-networkscripts-static-routes.html): in /etc/sysconfig/network-scripts/route-eth0, add a line like this:

10.20.1.0/24 dev eth0

GUI

When adding a route in system-config-network, some versions may generate an error when reopening: "Static routes file {interface_name} is invalid." To work around this, make sure to always fill in the gateway field (in this case, make it 0.0.0.0). This is a bug (which has since been fixed): see Red Hat Bug 153062.

Making Persistent (Debian/Ubuntu)

This is if you're not using Network Manager.

For the examples above, I added these lines to /etc/network/interfaces:

up route add -net 172.16.4.0 netmask 255.255.255.0 dev eth0
up route add -net 172.16.5.0 netmask 255.255.255.0 dev eth0

Routes in Windows

route ADD <DEST> MASK 255.255.255.0 <IP>

where <DEST> is e.g. 172.16.4.0 and <IP> is your local IP address.

To make persistent, use the -p option.

To list routes, run route PRINT.

info/routes.txt · Last modified: 2010-04-13 22:00 by sam