0

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

user1812956
  • 85
  • 1
  • 3
  • 10

4 Answers4

2

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
ALex_hha
  • 7,193
  • 1
  • 25
  • 40
1

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

GioMac
  • 4,544
  • 4
  • 27
  • 41
1

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
Shailesh
  • 179
  • 2
  • 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 06: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 06:55
0

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.

Satanicpuppy
  • 5,946
  • 1
  • 17
  • 18