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 10.10.0.1 eth0" > /etc/rc.d/rc.local
echo "route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 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:
10.1.0.0/16 via 10.2.0.1

#Add a route to a host:
10.1.2.3 via 10.0.0.5

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 😉

About Adriano Laranjeira

Software engineer & developer See more at http://about.me/arglbr
This entry was posted in English and tagged , , , . Bookmark the permalink.

1 Response to How to configure static routes in Fedora

  1. Pingback: Adriano Laranjeira » Blog Archive » Como configurar rotas estáticas no Fedora

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