Change Default gateway

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Change Default gateway
# 1  
Old 02-02-2013
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 !!
# 2  
Old 02-02-2013
Does

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

return anything? It might be defined twice.
# 3  
Old 02-04-2013
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
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:64Smilie3: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:64Smilie3: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 !!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Inconsistency between RedHat 6.5 global gateway and single gateway leads to loss of default gateway

Dear friends I use RedHat 6.5, which sets the gateway in the configuration file / etc / sysconfig / network as GATEWAY = 192.168.1.26, and the gateway in the configuration file / etc / sysconfig / network-scripts / ifcfg-eth11 as GATEWAY = 192.168.1.256. The two gateways are different.... (6 Replies)
Discussion started by: tanpeng
6 Replies

2. IP Networking

Default Gateway

I am am using IPv6 IP's with an OS of Debian. Is it possible to set a *static* default gateway w/o the router being connected? Will that gateway change when the router is connected? TIA (0 Replies)
Discussion started by: Meow613
0 Replies

3. UNIX for Dummies Questions & Answers

Cannot ping default gateway

I have NCR MP-RAS unix. I have been trying for several months to get our network working since we had never used it before. I have setup all routes that I can think of. I know it has something to do with the routing table, because out of sheer luck I was able to get it working, and than like a... (4 Replies)
Discussion started by: Rutgerncas
4 Replies

4. Linux

GNUGK-How to setup static gateway to gateway routing

Dear Sir I am a newbie in the world of IP telephony. I have been working with Asterisk PBX (SIP) and Cisco Call Manager (MGCP) but now I am learning on how to work GNUGK for H.323 Gatekeeper. I am having a problem, configuring static call routing on GNUGK in the section ... (0 Replies)
Discussion started by: mfondoum
0 Replies

5. HP-UX

where can i modify default gateway

where in configuration files can i modify default gateway in hp-ux11iv3 (5 Replies)
Discussion started by: h@foorsa.biz
5 Replies

6. Solaris

Change gateway without reboot server

Hi Gurus Recently i had change the gateway for a server i had change the IP in the /etc/defaultrouter and run the below command # route add default 10.86.33.222 # route delete default 10.86.33.1 # netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref ... (2 Replies)
Discussion started by: SmartAntz
2 Replies

7. AIX

Help with Default Gateway

Hi, I have two interfaces on m AIX 5.3 box. One going to 192.168.1.x and it has a gateway of 192.168.1.1. I configured the other gateway with 192.168.2.x and the default gateway as 192.168.2.1. But I can't get connectivity to the 192.168.2.1 network. Can someone help me out and let me know... (7 Replies)
Discussion started by: bbbngowc
7 Replies

8. Shell Programming and Scripting

script to change default route when primary gateway dies

Hello all! We have two fedora routers one at each site. What we are trying to do worked using freesco but not on fedora, i'm not very good at scripting and need a little guidence. Basicly what we are trying to do is if the primary line dies, the router will change it's routes to go through our... (0 Replies)
Discussion started by: slacker
0 Replies

9. Solaris

How can I change the default gateway?

my actual default gatewas IP is: default 192.168.11.254 and I need to change it to 192.168.11.2, I'm using Solaris 9, how can i do it? and how i can save it in case that the machine restart and have the new default gateway IP saved? (5 Replies)
Discussion started by: Lestat
5 Replies
Login or Register to Ask a Question