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 !!

Does

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

return anything? It might be defined twice.

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

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:64:D3: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:64:D3: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 !!