RHEL 7.4 - unexpected dynamic IP after reboot

Latest response

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

I have NetworkManager disabled and masked.

systemctl is-enabled NetworkManager

masked

Check if there are additional parameters set in the file (/etc/default/grub).

Wrong formatting... There are the next variables:

cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet" GRUB_DISABLE_RECOVERY="true"

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.)

Thank you for comment! My problem solved in the next comment thread with! It related to "dracut -vf" command.

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

I already have added this command.

# cat /etc/dracut.conf.d/99-disable_ifcfg.conf
omit_dracutmodules+="ifcfg"
# dracut -f

I followed the https://access.redhat.com/solutions/3017441 to exclude rewriting my ifcfg file by dracut.

Note: In case of there is no "omit_dracutmodules+="ifcfg"" my system have only one Dynamic IP. But I need Static IP. dracut rewrite my ifcfg each reboot with Dynamic configuration..

wrong comment

Ran dracut -vf again and it fixed my problem!

I understood my problem. My first run of dracut -f is in chroot section of kickstart... And as I understand it generate initramfs based on pxeboot initrd.img and vmlinuz. But last one should include section to auto configure network via dhcp (installer always configure network automatically). And It was root case of my problem. When I regenerate initramfs on installed system dracut exclude network configuration. Please correct me if I wrong.

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..?

I have "dracut-f" command into %post section of kickstart like here:

# cat /root/anaconda-ks.cfg
...
%post
...
echo 'omit_dracutmodules+="ifcfg"' >> /etc/dracut.conf.d/99-disable_ifcfg.conf
dracut -f
...
%end

%post section runs in installer not in installed system.

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.

I would like to note. If you need to regenerate initramfs from %post section of kickstart you need to omit network module:

# cat /root/anaconda-ks.cfg
...
%post
...
echo 'omit_dracutmodules+="ifcfg network"' >> /etc/dracut.conf.d/99-disable_ifcfg.conf
dracut -f
...
%end

dracut -vf was not fix my problem... I was wrong.

As I have added network module to omit in dracut.conf.d in my kickstart. And It fixed problem!

# cat /root/anaconda-ks.cfg
...
%post
...
echo 'omit_dracutmodules+="ifcfg network"' >> /etc/dracut.conf.d/99-disable_ifcfg.conf
dracut -f
...
%end

As I understood initramfs contains module to start network on early stage of OS boot. This feature need in case if my root partition located on /nfs , for example. So I have question. Why my static configuration was not reconfigure interface with static IP? It just add static IP to existing dynamic IP. I expects two things: 1) My network-scripts newer be rewrote. 2) I need o get static IP without dynamic IP..

Could you advice me right way to configure static IP on machine via kickstart? Or my way is right?

Wrong comment

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.