0

I have 2 NIC on server one is for internal communication with 10.10.10.X IP and other is 172.X.X.X IP for external communication.

I have route table like this

[root@hadoopslave1 ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.10.10.0      *               255.255.255.0   U     0      0        0 em1
172.X.X.0     *               255.255.255.0   U     0      0        0 em3
link-local      *               255.255.0.0     U     1002   0        0 em1
link-local      *               255.255.0.0     U     1004   0        0 em3
default         10.10.10.1      0.0.0.0         UG    0      0        0 em1

here the default route is through 10.10.10.1 gateway. i removed the default route and added new route for 172.X.X.1 Gateway but on reboot this is getting restored.

What changes are need to be made to make sure these changes will stay even after reboot.

Vikas Hardia
  • 283
  • 6
  • 15

3 Answers3

2

You'll probably have to dig around in /etc/sysconfig/network and /etc/sysconfig/network-scripts

The default gateway is determined by the network scripts which parse the /etc/sysconfig/network file first and then the network interface ifcfg files for interfaces that are “up”. The ifcfg files are parsed in numerically ascending order, and the last GATEWAY directive to be read is used to compose a default route in the routing table.

For CentOS 7 you may be looking for DEFROUTE directives in those files too see https://wiki.centos.org/FAQ/CentOS7

user9517
  • 115,471
  • 20
  • 215
  • 297
  • 10.10.10.1 gateway is em1 and 172.X.X.1 is em3 so what you are saying according to that, he should pick 172.X.X.1 as default route but its not happening. – Vikas Hardia Mar 14 '16 at 10:30
0

You need to put the route in /etc/sysconfig/network-scripts/route-em3 and put the route like this (obviously replace the IP class to match your one):

192.168.10.0/24 via 192.168.12.1 dev eth1

Then you can simply restart the network service service network restart and see that the route will be added. This will also make it persistent after reboot.

Mugurel
  • 903
  • 1
  • 9
  • 17
0

I am able to solve the problem it was due to DEFROUTE=yes entry in both NIC configuration, em1 and em3.

In em1 which is for internal communication i changed it to no and restarted the network services.

Vikas Hardia
  • 283
  • 6
  • 15