static route how?

Discussion regarding the installation and configuration of Linux distributions.
Post Reply
sonn33
Naik
Posts: 57
Joined: Wed Aug 25, 2004 3:20 pm
Location: Philippines
Contact:

static route how?

Post by sonn33 »

Hi! Guys,

How will i add my static route permanently to my linux box i have encountered problem that everytime i reboot my machine static route has gone. That's is why i have to re type it again.

# /sbin/route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.0.3

ThankS in advance.

Sonn
sonn33
mudasir
Captain
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Location: Dubai
Contact:

Post by mudasir »

AOA,

Dear son33,

Two methods by which it can be done are as follows
Method 1.

echo "/sbin/route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.0.3" >> /etc/rc.local

Easy and quick
Method 2.

Create a file /etc/sysconfig/network-scripts/route-ethX where X corresponds to the network interface you wish to use the alternate route. This file deals with three fields: GATEWAY, NETMASK, and ADDRESS. Each field should have a number appended to it indicating what route it relates to. The example below shows two static routes configured for the eth0 network interface.

touch /etc/sysconfig/network-scripts/route-eth0
vi /etc/sysconfig/network-scripts/route-eth0

GATEWAY=192.168.0.3
NETMASK=255.255.255.0
ADDRESS=192.168.5.0

save and exit by :wq

then

service network restart
Now its up to you which method will you choose.

Note: Method 2 only works on RedHat.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear sonn33,
Salam,

Duplicate post for the same question will not help you sir.

Best Regards.
Farrukh Ahmed
x2oxen
Major General
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:

Post by x2oxen »

add your route command in /etc/rc.local

/sbin/route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.0.3
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

Yaseen

Post by ghulam yaseen »

Hello :) ,

In addition to all above, please use this for changing route permenantly
------------
--> vi /etc/conf.d/net and add these lines

routes_eth1=(
"192.168.5.0 via 192.168.0.3"
)

I hope this will solve your issue 8)
mudasir
Captain
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Location: Dubai
Contact:

Post by mudasir »

AOA,

Dear Ghulam Yaseen,

I would request you to please discuss latest topics, these topics are very old and has been discussed many times.

Hope you dont mind.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

Post by ghulam yaseen »

Hi :),

I am new cadet at linux PK, so i was just for knowledge and if you dont mind, you can make me correct for any issue if i am wrong. I hope you will help this CADET8)
mudasir wrote:AOA,

Dear Ghulam Yaseen,

I would request you to please discuss latest topics, these topics are very old and has been discussed many times.

Hope you dont mind.
kbukhari
Major General
Posts: 1222
Joined: Sat Dec 31, 2005 12:29 am
Location: Lahore
Contact:

Post by kbukhari »

ghulam yaseen wrote:I hope you will help this CADET8)
this is army and we don't help cadets except push them to make us honorable.

This is not me, this is whole LP.
--
Syed Kashif Ali Bukhari
+92-345-8444420
http://sysadminsline.com
http://kashifbukhari.com
x2oxen
Major General
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:

Post by x2oxen »

kbukhari wrote:
ghulam yaseen wrote:I hope you will help this CADET8)
this is army and we don't help cadets except push them to make us honorable.

This is not me, this is whole LP.
Was that a first attack????
:P
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

Yaseen

Post by ghulam yaseen »

Yea 8)
x2oxen wrote:
kbukhari wrote:
ghulam yaseen wrote:I hope you will help this CADET8)
this is army and we don't help cadets except push them to make us honorable.

This is not me, this is whole LP.
Was that a first attack????
:P
x2oxen
Major General
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:

Post by x2oxen »

Then always try to save your a** as its going to be hard for newbie cause seniors out here are very strict and you will be criticized for every wrong move. :lol:
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
kbukhari
Major General
Posts: 1222
Joined: Sat Dec 31, 2005 12:29 am
Location: Lahore
Contact:

Post by kbukhari »

x2oxen wrote:Then always try to save your a** as its going to be hard for newbie cause seniors out here are very strict and you will be criticized for every wrong move. :lol:

thats why we don't own IP
--
Syed Kashif Ali Bukhari
+92-345-8444420
http://sysadminsline.com
http://kashifbukhari.com
x2oxen
Major General
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:

Post by x2oxen »

Thats why we don't own IP... what does that means ???
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
kbukhari
Major General
Posts: 1222
Joined: Sat Dec 31, 2005 12:29 am
Location: Lahore
Contact:

Post by kbukhari »

x2oxen wrote:Thats why we don't own IP... what does that means ???
Intellectual Property.
--
Syed Kashif Ali Bukhari
+92-345-8444420
http://sysadminsline.com
http://kashifbukhari.com
x2oxen
Major General
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:

Post by x2oxen »

Lolzzz! :P
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
Post Reply