RHEL 7.4 - unexpected dynamic IP after reboot
Hello.
Unexpected dynamic IP on the interface:
# ip add show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether MAC brd ff:ff:ff:ff:ff:ff
inet DYNAMIC_IPv4 brd MY_BRD scope global dynamic enp1s0
valid_lft 12510sec preferred_lft 12510sec
inet STATIC_IPv4 brd MY_BRD scope global secondary enp1s0
valid_lft forever preferred_lft forever
inet6 DYNAMIC_IPv6 scope link
valid_lft forever preferred_lft forever
I use network instead NetworkManager. NetworkManager turned off.
For my network interface there is only one config file with static IP.
But in /var/log/message there are dhclient strings about dynamic IP durin boot.
Oct 5 02:38:01 myhostname kernel: r8169 0000:01:00.0 enp1s0: link down
Oct 5 02:38:01 myhostname kernel: r8169 0000:01:00.0 enp1s0: link down
Oct 5 02:38:01 myhostname kernel: IPv6: ADDRCONF(NETDEV_UP): enp1s0: link is not ready
Oct 5 02:38:05 myhostname kernel: r8169 0000:01:00.0 enp1s0: link up
Oct 5 02:38:05 myhostname kernel: IPv6: ADDRCONF(NETDEV_CHANGE): enp1s0: link becomes ready
Oct 5 02:38:07 myhostname dracut-initqueue: dhcp: PREINIT enp1s0 up
Oct 5 02:38:07 myhostname dhclient[550]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 3 (xid=0x739eee84)
Oct 5 02:38:07 myhostname dhclient[550]: DHCPREQUEST on enp1s0 to 255.255.255.255 port 67 (xid=0x739eee84)
Oct 5 02:38:08 myhostname dracut-initqueue: dhcp: BOND setting enp1s0
Oct 4 23:39:22 myhostname ntpd[1343]: Listen normally on 3 enp1s0 DYNAMIC_IPv4 UDP 123
Oct 4 23:39:22 myhostname ntpd[1343]: Listen normally on 5 enp1s0 DYNAMIC_IPv6 UDP 123
Oct 4 23:40:01 myhostname network: Bringing up interface enp1s0: [ OK ]
Oct 4 23:40:01 myhostname ntpd[1643]: Listen normally on 3 enp1s0 DYNAMIC_IPv4 UDP 123
Oct 4 23:40:01 myhostname ntpd[1643]: Listen normally on 4 enp1s0 Static_IPv4 UDP 123
Oct 4 23:40:01 myhostname ntpd[1643]: Listen normally on 6 enp1s0 DYNAMIC_IPv6 UDP 123
If I do systemctl restart network then dynamic ip disappear. But after reboot machine have two IP again..
UPDATE:
After 9 hours without any intervention DHCP IP was released...
# ip add show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether MAC brd ff:ff:ff:ff:ff:ff
inet STATIC_IPv4 brd MY_BRD scope global enp1s0
valid_lft forever preferred_lft forever
inet6 IPv6 scope link
valid_lft forever preferred_lft forever
Also: I have the next new message in /var/log/messages:
Oct 5 03:38:10 myhostname ntpd[1643]: Deleting interface #3 enp1s0, DYNAMIC_IPv4#123, interface stats: received=260, sent=260, dropped=0, active_time=14290 secs
Responses
Is NetworkManager disabled as well as being off? That might explain why you get a DHCP address on reboot.
# systemctl is-enabled NetworkManager
disabled
Check if there are additional parameters set in the file (/etc/default/grub).
That tells us what boot options would be used if the GRUB configuration file was regenerated. But what are the current boot options that are actually in effect right now?
Please show the output of the following commands:
cat /proc/cmdline
cat /boot/grub2/grubenv
grep linux /boot/grub2/grub.cfg # if legacy MBR system
grep linuxefi /boot/efi/EFI/redhat/grub.cfg # if UEFI-based system
(According to https://access.redhat.com/solutions/3017441 dracut will activate network interfaces and rewrite the network configuration files only if there are network-related boot options in the kernel command line.)
Oct 5 02:38:07 myhostname dracut-initqueue: dhcp: PREINIT enp1s0 up
DHCP query happens in dracut-initqueue. It's highly possible that it happened in initramfs. Try to re-create the initramfs with dracut command.
# dracut -vf
That is good....
But last one should include section to auto configure network via dhcp (installer always configure network automatically)
Check your /root/anaconda-ks.cfg to understand about the kickstart settings used during installation. Not sure, if I've understood your query correctly..?
Looks like you're correct.
More specifically, when %post runs, the system still has the boot options used for the installation visible in /proc/cmdline... and that is probably the thing that is leading dracut to add the network configuration scripts to the initramfs.
In kickstart configuration, %post --nochroot runs in a "pure" installer environment, while plain %post without the --nochroot option will run chrooted in the installed system, but the system is still running "on" the installer; it has not yet booted on its own at that point. And the chroot will also see /proc/cmdline as it exists for the installer.
Good catch. I'll have to remember this too, when customizing RHEL 7 installs.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
