Change Default gateway | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

Change Default gateway

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-02-2013
deljatt deljatt is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 6 February 2013, 7:06 AM EST
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Change Default gateway

Hi..I have to change default gateway in my linux machine. Its OS is RHEL6.
I followed following steps.
1.run command ip route to check current default gateway
2.delete that gateway with command
route del default gw x.x.x.x eth2
3.Add new gatewy with command below
route add default gateway x.x.x.x eth0
4.Also ensure /etc/sysconfig/network has new gateway entry with eth name in it.
NETWORKING=yes
HOSTNAME=N1
GATEWAY=x.x.x.x
GATEWAYDEV=eth0

But when we restart network service it moves back to old gateway.

Kindly let me know how to make it permanent.

Thanks !!
Sponsored Links
    #2  
Old 02-02-2013
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Does


Code:
grep GATEWAY /etc/sysconfig/network-scripts/ifcfg-eth*

return anything? It might be defined twice.
Sponsored Links
    #3  
Old 02-04-2013
deljatt deljatt is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 6 February 2013, 7:06 AM EST
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Hi..i have 4 lan port configured with different gateway. when i tried running command getting below output.

/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=x1.x2.x3.x4
/etc/sysconfig/network-scripts/ifcfg-eth1:GATEWAY=x11.x12.x13.x14
/etc/sysconfig/network-scripts/ifcfg-eth2:GATEWAY=x21.x22.x23.x24
/etc/sysconfig/network-scripts/ifcfg-eth3:GATEWAY=x31.x32.x33.x34
    #4  
Old 02-06-2013
deljatt deljatt is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 6 February 2013, 7:06 AM EST
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Hi..my data center is in location x and person accessing it on Y over wan.Server has linux RHEL 6.2 OS and has 4 nic card with their different ip(Ip1,Ip2,Ip3 & Ip4),netmask and gateway (gw1 to gw4). Person from Y is able to ping gateway gw1 to gw4. When he tried to ping ip , he is able to ping Ip1.

Do i need to define default gateway for all ip? How shall i configure default gateway for rest of IP's?


INTERFACE IP Gateway Subnet Remarks
ce0 192.12.80.1 192.12.80.254 255.255.255.0
ce0:1 192.12.80.2 192.12.80.254 255.255.255.0 It is virtual IP
ce1 192.12.81.5 192.12.80.126 255.255.255.128
ce2 192.12.83.4 192.12.80.254 255..255.255.192
ce3 192.168.176.1 192.168.176.254 255.255.255.0

Pls find below details as required.


[root@NORTH01 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:1A:643:FD:54
inet addr:192.12.80.1 Bcast:10.2.180.255 Mask:255.255.255.0
inet6 addr: fe80::21a:64ff:fed3:fd54/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10955 errors:0 dropped:0 overruns:0 frame:0
TX packets:4868 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3273759 (3.1 MiB) TX bytes:1554244 (1.4 MiB)
Interrupt:16 Memory:ce000000-ce012800

eth1 Link encap:Ethernet HWaddr 00:1A:643:FD:56
inet addr:192.12.81.5 Bcast:10.2.181.127 Mask:255.255.255.128
inet6 addr: fe80::21a:64ff:fed3:fd56/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6760 errors:0 dropped:0 overruns:0 frame:0
TX packets:5464 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7758932 (7.3 MiB) TX bytes:522470 (510.2 KiB)
Interrupt:17 Memory:ca000000-ca012800

eth2 Link encap:Ethernet HWaddr 00:15:17:78:5F:9E
inet addr:192.12.83.4 Bcast:10.2.181.191 Mask:255.255.255.192
inet6 addr: fe80::215:17ff:fe78:5f9e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4458 errors:0 dropped:0 overruns:0 frame:0
TX packets:3930 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4428694 (4.2 MiB) TX bytes:365910 (357.3 KiB)
Interrupt:16 Memory:c7ee0000-c7f00000

eth3 Link encap:Ethernet HWaddr 00:15:17:78:5F:9F
inet addr:192.168.176.1 Bcast:192.168.176.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe78:5f9f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3634 errors:0 dropped:0 overruns:0 frame:0
TX packets:3558 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:896806 (875.7 KiB) TX bytes:896716 (875.6 KiB)
Interrupt:17 Memory:c7ea0000-c7ec0000

eth4 Link encap:Ethernet HWaddr 00:15:17:78:61:94
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:17 Memory:c5fe0000-c6000000

eth5 Link encap:Ethernet HWaddr 00:15:17:78:61:95
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:18 Memory:c5fa0000-c5fc0000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3755 errors:0 dropped:0 overruns:0 frame:0
TX packets:3755 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1096013 (1.0 MiB) TX bytes:1096013 (1.0 MiB)

[root@NORTH01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.2.181.128 0.0.0.0 255.255.255.192 U 0 0 0 eth2
10.2.181.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
192.168.176.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
10.2.180.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1005 0 0 eth3
0.0.0.0 192.12.80.254 0.0.0.0 UG 0 0 0 eth0
[root@NORTH01 ~]#
[root@NORTH01 ~]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.2.181.128 0.0.0.0 255.255.255.192 U 0 0 0 eth2
10.2.181.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
192.168.176.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
10.2.180.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth3
0.0.0.0 192.12.80.254 0.0.0.0 UG 0 0 0 eth0

Thanks !!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
GNUGK-How to setup static gateway to gateway routing mfondoum Linux 0 08-12-2010 06:54 AM
Change gateway without reboot server SmartAntz Solaris 2 12-30-2009 10:48 AM
Help with Default Gateway bbbngowc AIX 7 02-20-2009 01:00 AM
script to change default route when primary gateway dies slacker Shell Programming and Scripting 0 05-24-2006 12:34 PM
How can I change the default gateway? Lestat Solaris 5 03-28-2005 06:03 PM



All times are GMT -4. The time now is 05:32 PM.