command-hostInstant setup vpsInstant windows vps“route” quickJusthost com coupondoesn’taddress static inetWeb hosting resellertakes

This post is to help you set up a static persistent route or routes on your Debian and/or Ubuntu.

Servers are generally hooked up to multiple subnets and when need be, your destination is connected to a NIC that isn’t your default gateway. You can only have 1 default route. Having two will cause lots of weird problems.

Check your routes first. A simple “route” command will show you the routes. Some people like “netstat -r”.

Edit /etc/network/interfaces and make sure you only see “gateway” once. If you have two, leave it on the NIC that takes you out to the internet.

Here is the NIC config we need to set up the static routes for:
allow-hotplug eth1
iface eth1 inet static

To make something route over that interface since it doesn’t have a gateway and isn’t in that subnet, we can add:

#Static routes for VPL
up route add -net gw dev eth1
up route add -net gw dev eth1

The first IPs are the networks you need to hit. The second IP after “gw” is the gateway for that network, that will route you to the other networks. eth1 is the interface for which you are going out, pretty self explanatory.

NOTE: If you only need to hit a single host route and not a network route, change the line to this:

up route add -host gw dev eth1

Now, restart Networking or just reboot. Then a quick “route” or “route -n” (to keep it from trying to do a reverse DNS lookups on the IPs) command will show you your new static routes.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>