Home > Linux, Networking, Windows > Persistent static routes

Persistent static routes

I wanted to direct traffic to the network 192.168.1 via rather than via the default gateway and this is how I did it. It is kind of basic, but it varies between platforms.

In Windows it is very easy, simply run:

route -p add mask metric 10

The route is added immediately and will survive restarts.

For Red Hat Linux, CentOS and their relatives, create a file in /etc/sysconfig/network-scripts named route-ethX where X is the interface number. In my case I created the file /etc/sysconfig/network-scripts/route-eth0. The file should contain:


where N is the route number. In my example:


Finally for Ubuntu and other Debian-related Linux versions, modify the file /etc/network/interfaces and add an up command. In my case I added:

up route add -net netmask gw eth0

Including the other lines for eth0 this resulted in:

iface eth0 inet static
up route add -net netmask gw eth0
auto eth0
Categories: Linux, Networking, Windows
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: