How to configure static routes in Fedora

Você pode ver este post em português também.

Routes. The unique way I like to see them:

Signs and routes

Recently I had to do a fix inside the routing table of a server. I’ve found out a better and more elegant way than this usual:

touch /etc/rc.d/rc.local
echo "touch /var/lock/subsys/local" > /etc/rc.d/rc.local
echo "route add default gw eth0" > /etc/rc.d/rc.local
echo "route add -net netmask gw eth0" > /etc/rc.d/rc.local

Inside Fedora GNU/Linux, static routes can be added in specific files for each one of its interfaces. These files are located at /etc/sysconfig/network-scripts/. The filename must match the route-ifname format. So if you want to add a route to the eth0 interface, the filename must be called /etc/sysconfig/network-scripts/route-eth0. It’s an important detail because an error naming in this file isn’t able to produce any error/warning log in anywhere.

The file content is quite simple. The examples below worth more than the explanation:

#Add a route to a network: via

#Add a route to a host: via

After done, is possible to test your new routes using the ifup-routes ifname command. It adds the configured routes to the active routes table.


See you 😉

One thought on “How to configure static routes in Fedora

Leave a Reply

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

You are commenting using your 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