I have a Minimal Install of CentOS 7.
I have disabled the Network Manager as I want to setup my network the "old school" way.
systemctl stop NetworkManager
systemctl disable NetworkManager
chkconfig network on
service network restart
My network config (/etc/sysconfig/network-scripts/ifcfg-ens4) looks like this:
DEVICE="ens4"
TYPE="Ethernet"
NOZEROCONF="yes"
PERSISTENT_DHCLIENT="1"
BOOTPROTO="dhcp"
DEFROUTE="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
NAME="ens4"
ONBOOT="yes"
NM_CONTROLLED="no"
My DHCP lease-file looks like this:
lease {
interface "ens4";
fixed-address 144.76.190.238;
option subnet-mask 255.255.255.255;
option routers 144.76.190.224;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 8.8.8.8,8.8.4.4;
option dhcp-server-identifier 144.76.190.224;
option host-name "hello.example.com";
option domain-name "example.com";
renew 2 2014/10/21 05:44:47;
rebind 2 2014/10/21 15:04:03;
expire 2 2014/10/21 18:04:03;
}
Now, my problem is that the "routers" field from the DHCP seems to get ignored by CentOS 7. IP, netmask and hostname is being set correctly, but my default route is not being set (blank).
As you can see, I am using netmask 255.255.255.255 so the gateway IP is "outside" of my network. Therefor an extra route is needed. If I run these manually:
route add -host 144.76.190.224 dev ens4
route add default gw 144.76.190.224
Then everything works fine:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 144.76.190.224 0.0.0.0 UG 0 0 0 ens4
144.76.190.224 0.0.0.0 255.255.255.255 UH 0 0 0 ens4
All other linux distributions I have tested, including Centos 6, works fine and sets these 2 routes automatically from the DHCP.
So my question is this; Why does it not getting set automatically in CentOS 7? Did something change and I have to add some additional flags to the DHCP client for it to work?
It seems that CentOS 6 uses dhclient version 4.1.1-P1 and CentOS 7 uses 4.2.5. Maybe they changed something between those versions?
UPDATE 1:
I looked at the release notes of dhclient and found this for 4.0.0:
"The dhclient-script was updated to create a host route for the default gateway if the supplied subnet mask for an IPv4 address was a /32. This allows the client to work in 'captive' network environments, where the operator does not want clients to crosstalk directly."
So this should have been working since long time ago. Maybe CentOS 7 has removed it from the "dhclient-script"?
UPDATE 2:
I copied the file "/sbin/dhclient-script" from a CentOS 6 installation to the CentOS 7 server. Now everything works fine. I will investigate what changes they have done, but it seems they have introduced a bug in CentOS 7.
UPDATE 3:
I figured out the issue. They added a (stupid) ping check in the new version of /sbin/dhclient-script that tries to ping the gateway before adding it. As I am blocking pings in my firewall on the DHCP server, it did not answer and therefor the dhclient-script did not add any default route.