Centos – /etc/sysconfig/network is ignored on CENTOS7

centosnetworking

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?

Best Answer

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)

Related Topic