3

I have a server with two NIC's. The default gateway has to be on a specific one, therefore I configured the GW via /etc/sysconfig/network. But obviousely, this is completely ignored by the NetworkManager

[root@node1 ~]# cat /etc/sysconfig/network
GATEWAY="10.100.20.1"
[root@node1 ~]# systemctl restart network
[root@node1 ~]# ip r s
default via 10.100.7.1 dev ens160  proto static  metric 1024
10.100.7.0/24 dev ens160  proto kernel  scope link  src 10.100.7.31
10.100.20.0/22 dev ens192  proto kernel  scope link  src 10.100.20.204

Any hints?

EDIT: Here are the interface configurations:

[root@node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192
DEVICE="ens192"
ONBOOT=yes
NETBOOT=yes
UUID="e634ce78-f5ea-4b3c-b3ea-1e40ef0b11ac"
BOOTPROTO=none
IPADDR="10.100.20.204"
NETMASK="255.255.252.0"
GATEWAY="10.100.20.1"
HWADDR="XXX"
TYPE=Ethernet
NAME="ens192"
DNS1="193.12.103.2"

[root@node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160
DEVICE="ens160"
ONBOOT=yes
NETBOOT=yes
UUID="bee8e636-80b4-45f3-9b74-eb9eb0fed38d"
BOOTPROTO=none
IPADDR="10.100.7.31"
NETMASK="255.255.255.0"
GATEWAY="10.100.7.1"
HWADDR="XXX"
TYPE=Ethernet
NAME="ens160"
DNS1="193.12.103.2"

And here's a part from messages that probably causes the Issue:

[root@node1 ~]# cat /var/log/messages | grep NetworkManager | grep "Nov  9" | grep "as default for IPv4" -A5 -B5
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> (ens192): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> Activation (ens192) Stage 5 of 5 (IPv4 Commit) complete.
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> (ens160): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> (ens192): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> (ens160): device state change: secondaries -> activated (reason 'none') [90 100 0]
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> Policy set 'ens160' (ens160) as default for IPv4 routing and DNS.
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> Activation (ens160) successful, device activated.
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> (ens192): device state change: secondaries -> activated (reason 'none') [90 100 0]
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> NetworkManager state is now CONNECTED_GLOBAL
Nov  9 12:24:36 logging-02 NetworkManager[631]: <info> Activation (ens192) successful, device activated.
Nov  9 12:24:41 logging-02 NetworkManager[631]: <info> startup complete

Any idea what kind of "Policy" is mentioned there?

  • I can just assure you that it's not ignored because I'm using it to configure the default gateway. May be it's the systemctl restart network is not enough to actually redefine the default gateway. – drookie Nov 8 '14 at 13:01
  • 1
    Check the configuration of each interface. – Michael Hampton Nov 8 '14 at 14:45
  • 1
    @EugeneM.Zheganin Reboot does not work either, and systemctl restart network should definitely do it... – sontags Nov 9 '14 at 11:23
3

This worked:

[root@node1 ~]# cat /usr/share/doc/initscripts-9.49.17/sysconfig.txt | grep DEFROUTE
DEFROUTE=yes|no (set this interface as default route? yes is default)

I still believe that ignoring /etc/sysconfig/network is a bug in CentOS Linux release 7.0.1406 (Core)

  • 1
    Fixed my issue. Just to make it clear to everyone: you must explicitly configure DEFROUTE=no in the config file for all other UP interfaces on your server for this to work properly. I really hope /etc/sysconfig/network being configured is a bug (two years later?!?!!?), because having to configure a default route this way is absolutely ridiculous... – lobi Oct 24 '16 at 21:34
0

The best way I've done this is addd a static route file like I have two interfaces

eth0 = private on 10.10.11.10
eth1 = public on 1.2.3.4 (also the default route)

So if I want all internal traffic on the 10.0.0.0/8 subnet to go out eth0 I just add the following file

/etc/sysconfig/network-scripts/route-eth0

With the contents of

default 10.102.51.129 dev eth0
10.0.0.0/8 via 10.102.51.129 dev eth0

10.102.51.129 is my gateway for eth0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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