How to Add Persistent or Static Routes to CentOS 5.9 and 6

2
2/5/2015 How To Add Persistent or Static Routes to CentOS 5.9 and 6.4 | WING LOON data:text/html;charset=utf8,%3Cheader%20class%3D%22entryheader%22%20style%3D%22boxsizing%3A%20borderbox%3B%20display%3A%20block%… 1/2 How To Add Persistent or Static Routes to CentOS 5.9 and 6.4 SEPTEMBER 13, 2013 BY WINGLOON · COMMENTS OFF In this how to, I am going to share how to add persistent or static routes on CentOS 5.9 and 6.4 versions. Assuming the network information below configured on the server itself with one network interface card, eth0: – Interface: eth0 IP Address: 172.16.0.1 Netmask: 255.255.255.0 Gateway: 172.16.0.254 We need to add two static routes below and these routes don’t route to the default route of eth0 interface, 172.16.0.254: – Interface: eth0 Address: 192.168.1.0 Netmask: 255.255.255.0 Gateway: 172.16.0.11 Interface: eth0 Address: 10.20.30.0 Netmask: 255.255.255.0 Gateway: 172.16.0.12 Here is how we can do it by creating this /etc/sysconfig/networkscripts/routeeth0 file. You have two ways to define the content. I had tested on CentOS 5.9 and 6.4 version and it works. Option 1, include the below in /etc/sysconfig/networkscripts/routeeth0 file: – GATEWAY0=172.16.0.11 NETMASK0=255.255.255.0 ADDRESS0=192.168.1.0 GATEWAY1=172.16.0.12 NETMASK1=255.255.255.0 ADDRESS1=10.20.30.0 Option 2, include the below in /etc/sysconfig/networkscripts/routeeth0 file: –

description

How to Add Persistent or Static Routes to CentOS 5.9 and 6

Transcript of How to Add Persistent or Static Routes to CentOS 5.9 and 6

  • 2/5/2015 HowToAddPersistentorStaticRoutestoCentOS5.9and6.4|WINGLOON

    data:text/htmlcharset=utf8,%3Cheader%20class%3D%22entryheader%22%20style%3D%22boxsizing%3A%20borderbox%3B%20display%3A%20block% 1/2

    HowToAddPersistentorStaticRoutestoCentOS5.9and6.4SEPTEMBER13,2013BYWINGLOON COMMENTSOFF

    Inthishowto,IamgoingtosharehowtoaddpersistentorstaticroutesonCentOS5.9and6.4versions.Assumingthenetworkinformationbelowconfiguredontheserveritselfwithonenetworkinterfacecard,eth0:

    Interface:eth0

    IPAddress:172.16.0.1

    Netmask:255.255.255.0

    Gateway:172.16.0.254

    Weneedtoaddtwostaticroutesbelowandtheseroutesdontroutetothedefaultrouteofeth0interface,172.16.0.254:

    Interface:eth0

    Address:192.168.1.0

    Netmask:255.255.255.0

    Gateway:172.16.0.11

    Interface:eth0

    Address:10.20.30.0

    Netmask:255.255.255.0

    Gateway:172.16.0.12

    Hereishowwecandoitbycreatingthis/etc/sysconfig/networkscripts/routeeth0file.Youhavetwowaystodefinethecontent.IhadtestedonCentOS5.9and6.4versionanditworks.

    Option1,includethebelowin/etc/sysconfig/networkscripts/routeeth0file:

    GATEWAY0=172.16.0.11

    NETMASK0=255.255.255.0

    ADDRESS0=192.168.1.0

    GATEWAY1=172.16.0.12

    NETMASK1=255.255.255.0

    ADDRESS1=10.20.30.0

    Option2,includethebelowin/etc/sysconfig/networkscripts/routeeth0file:

  • 2/5/2015 HowToAddPersistentorStaticRoutestoCentOS5.9and6.4|WINGLOON

    data:text/htmlcharset=utf8,%3Cheader%20class%3D%22entryheader%22%20style%3D%22boxsizing%3A%20borderbox%3B%20display%3A%20block% 2/2

    192.168.1.0/24via172.16.0.11deveth0

    10.20.30.0/24via172.16.0.12deveth0

    Youcanrestartthenetworkservicetohavethechangestotakeeffectusingthiscommand:

    #servicenetworkrestart

    Ifthereisnoerror,youcanverifytheroutesusingthiscommand:

    #routen

    or

    #netstatrn

    Yourrouteswillbeaddedautomaticallyaftereveryreboot.Pleasenotethatifyouneedtoaddroutestoeth1interfacethenyouneedtocreate/etc/sysconfig/networkscripts/routeeth1file.Hopethishelpsyou.Thankyou.