Friday, August 3, 2007

5 SysAds permanent static route story

How to make static route permanent in many alternative ways?

Interesting world of linux, we get a lot of alternative approach on how to accomplish tasks, big or small.

Considering a multi-homed machine and/or machine inside VLAN with a gateway, ever wonder alternative wonder ways of making static routes permanent after reboots?

My Five SysAd Story.

There are five SysAds working with 5 different fortune companies. They all grew up in a small town, next to each other's house. And still, after all those decades, they manage to keep in touch and still befriends with one another.

One day, after a tiring Friday work they all decided to see each other and have some drink, some good old time in one bar like they used before.

Late before midnight, suddenly 5 of them begun discussing about a very simple task of creating and making static routes permanent between reboots.

Here are how their linux discussion goes....

First SysAd:

That one would be as easy as windows startup programs. Lanuch vi, and edit /etc/rc.local, put your static route commands there and you are good to go. Just make sure you have already assigned IP address for each network subnet t all your virtual ethernet interface

TRANSLATION:
The first guy was referring to these approach as follow

As all of them needs to assign static IP address first, like so

# ifconfig eth0:0 192.168.20.10 netmask 255.255.255.0 up
# ifconfig eth0:0 192.168.30.10 netmask 255.255.255.0 up
# ifconfig eth0:0 192.168.40.10 netmask 255.255.255.0 up
# ifconfig eth0:0 192.168.50.10 netmask 255.255.255.0 up

With these virtual IP aliases and assumming a single default gateway of 192.168.60.1 .

First sysad discussed to edit system boot up file /etc/rc.local

# nano -w /etc/rc.local

and add sample static routes

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.60.1
route add -net 192.168.30.0 netmask 255.255.255.0 gw 192.168.60.1
route add -net 192.168.40.0 netmask 255.255.255.0 gw 192.168.60.1
route add -net 192.168.50.0 netmask 255.255.255.0 gw 192.168.60.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

then save and reboot.

Legend:
192.168.60.1 = mother gateway
192.168.20.0 = first network subnet
192.168.30.0 = 2nd network subnet
192.168.40.0 = 3rd network subnet

Second SysAd:


Man, the beer is really good and you are just putting too much of muscle energy from your finger and hands. Simply use the mouse, launch Gnome network property settings and add all the needed static routes you need from there and reboot.


TRANSLATION:

When using Gnome X, you can actually press Ctrl+F2 to execute a command. Type system-config-network to launch network property settings.

The same like System > Administration > Network using mouse movements.

Inside the newly appeared window, select the particular device interface. Click Edit menu button.
A new window appears after clicking Edit.

Go to Route tabbed menu and select Add button. From there, continue adding all the needed static routes. Click OK. Do not forget to save your static route, Ctrl+S.

Click on Deactivate and Activate to restart the new network route changes. Reboot and see.

Third SysAd, which is linux-taught by the First SysAd:

Compadres, simply edit the static route files directly and add all your static routes there. Do Network restart, that's it.

TRANSLATION:

Launch CLI terminal editor and create and edit all static route files.

# nano -w /etc/sysconfig/network-scripts/route-eth0:0

append these lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GATEWAY0=192.168.60.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.20.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# nano -w /etc/sysconfig/network-scripts/route-eth0:1

append these lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GATEWAY0=192.168.60.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.30.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# nano -w /etc/sysconfig/network-scripts/route-eth0:2

append these lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GATEWAY0=192.168.60.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.40.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# nano -w /etc/sysconfig/network-scripts/route-eth0:3

append these lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GATEWAY0=192.168.60.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.50.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and restart the network like so

# service network restart
# reboot;

EDITED:

OR

# nano -w /etc/sysconfig/network-scripts/route-eth0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GATEWAY0=192.168.60.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.20.10

GATEWAY1=192.168.60.1
NETMASK1=255.255.255.0
ADDRESS1=192.168.30.10

GATEWAY2=192.168.60.1
NETMASK2=255.255.255.0
ADDRESS2=192.168.40.10

GATEWAY3=192.168.60.1
NETMASK3=255.255.255.0
ADDRESS3=192.168.50.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# service network restart



Fourth SysAd. He does not talk too much. And linux was introduced and taught to him by the Second SysAd. So he goes

I'd probably go launching and doing it in CLI mode as well using network property settings.

TRANSLATION:

# system-config-network-tui

and follow the Second SysAd approach

The 4 of them agreed with one another. Fifth sysad was tired and already drunk. But he continues

FIFTH SYSAD

Well, what do you know, linux had kept us closer. Static routes is static-routes.

IMMEDIATE TRANSLATION:

Simply create and edit the file /etc/sysconfig/static-routes

# vi /etc/sysconfig/static-routes

and append
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
any net 192.168.20.0 netmask 255.255.255.0 gw 192.168.60.1
any net 192.168.30.0 netmask 255.255.255.0 gw 192.168.60.1
any net 192.168.40.0 netmask 255.255.255.0 gw 192.168.60.1
any net 192.168.50.0 netmask 255.255.255.0 gw 192.168.60.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# service network restart

That is how my Five SysAd story goes, way too different from the 5 Horsemen of Apocalypse.

Now, here's the question.

Among the 5 SysAds, which one works with RedHat company?

:)

Thanks for reading.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy