http://www.alper.net/ Eyup Alper Yoney

26Nov/090

Configuring Static Routes on Linux

How to configure static routes on linux ?

This question has been asked many times and I decided to keep the answer here. Actually there is no accurate answer because it depends on the distribution. Therefore this solution covers only RedHat and Fedora.

Static route configuration is stored in a /etc/sysconfig/network-scripts/route-interface file. For eth0, static routes would be stored in the /etc/sysconfig/network-scripts/route-eth0 file.

The route-interface file has two formats:

IP Command Arguments Format

default 192.168.0.1 dev eth0
10.0.0.0/24 via 192.168.0.1 dev eth0
192.168.1.0/24 via 192.168.0.1 dev eth0


Network/Netmask Directives Format

ADDRESS0=10.0.0.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.0.1
ADDRESS1=192.168.1.0
NETMASK1=255.255.255.0
GATEWAY1=192.168.0.1