Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

am trying to change default to route to eth2 my present rout -n o/p--

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.235.4.0      *               255.255.255.0   U     0      0        0 eth3
10.235.3.0      *               255.255.255.0   U     0      0        0 eth2
10.235.2.0      *               255.255.255.0   U     0      0        0 eth0
169.X.0.0     *               255.255.0.0     U     0      0        0 eth3
default         10.235.4.1      0.0.0.0         UG    0      0        0 eth3

IP ro sh - output

# ip ro sh
10.235.4.0/24 dev eth3  proto kernel  scope link  src 10.235.4.21
10.235.3.0/24 dev eth2  proto kernel  scope link  src 10.235.3.21
10.235.2.0/24 dev eth0  proto kernel  scope link  src 10.235.2.21
169.x.0.0/16 dev eth3  scope link
default via 10.235.4.1 dev eth3

What i am trying to do is

> Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.235.4.0      *               255.255.255.0   U     0      0        0 eth3
10.235.3.0      *               255.255.255.0   U     0      0        0 eth2
10.235.2.0      *               255.255.255.0   U     0      0        0 eth0
169.x.0.0       *               255.255.0.0     U     0      0        0 eth3
default         10.235.2.1      0.0.0.0         UG    0      0        0 eth2

I tryed different ways a> add "gatewaydev=eth2" in/etc/sysconfig/network.
b> added route eth2 by command and deleted eth3 route entry.

after service network restart it going back to first output.

help me thanks

share|improve this question
add comment

4 Answers 4

Just add/replace default gateway ip address to/in the /etc/sysconfig/network

GATEWAY=10.235.2.1

And then restart the newtwork service

# service network restart
share|improve this answer
    
I have as gateway=eth0 but still not working –  user1812956 Aug 30 '13 at 16:15
    
add output of the # ip ro sh to your question –  ALex_hha Aug 30 '13 at 16:28
add comment

You must have address from 10.235.2.0 network on eth2 first, then you can change GATEWAY= value.

share|improve this answer
    
Yea , I have . I added eth0 interrface in dhcp server which is 10.235.0.2 scope –  user1812956 Aug 31 '13 at 7:00
add comment

Open /etc/sysconfig/network file:

#vi  /etc/sysconfig/network

Setup GATEWAY={Router-IP}

GATEWAY=10.235.2.1

You need to restart networking service:

# /etc/init.d/networking restart
share|improve this answer
    
It is working fine wirth i keep gateway address as 10.235.2.1 , but iwant go by device not by gateway-ip –  user1812956 Aug 31 '13 at 6:51
    
Run command setup then go to menu network configuration and select the ethernet card(NIC) which you want to configure and setup gateway ip there. –  Shailesh Aug 31 '13 at 6:55
add comment

I tend to add the gateway to the /etc/sysconfig/network-scripts/ifcfg-ethX config file for the appropriate interface, eg:

BOOTPROTO=none
DEVICE=eth0
ONBOOT=yes
SLAVE=no
IPADDR=10.20.30.40
NETMASK=255.255.255.0
GATEWAY=10.20.30.1
USERCTL=no
BROADCAST=10.20.30.255

I tend not to put it in /etc/sysconfig/network, though you certainly can. I do a lot of really complex bonding configurations, and it makes it easier if all the files are in one place.

If you do it like I do it, DO NOT declare the gateway interface in other IFCFG files. It will read them in order, resetting the gateway every time, and you won't get the expected behaviour.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.