Hands-on Lab: Initializing Network Connectivity

I have some confusion about this lab


Why /etc/resolv.conf is empty at first place . As bootproto is set to DHCP , shouldn't the nameserver be populated automatically ?

My understanding is that resolv.conf shoudn't be modidfied directly as it is overwritten by NetworkManager (i think if DHCP is being used ?)

Whats the best approach for setting nameserver. 

1) If I set DNS servers using nmcli or nmtui and keep connection mode manual then after restarting network.service , /etc/resolv.conf must show the DNS servers I configured

2) if DHCP is set then /etc/resolv.conf must have nameservers assigned by DHCP automatically I guess ?

Any idea why above two points dont work in this lab until nameserver is manually set in resolv.conf ?Also is it right approach to do this ?



  • post-author-pic
    Jake W

    Bumping this question up. I'm also curious about how this works, but I can add that both of these methods work simultaneously. You can use nmcli to add a DNS server to a specific ifcfg script, even if it uses DHCP to get a first DNS server assigned to it on boot. If you do both, on reboot you'll see both in /etc/resolv.conf

    Of course, like you said, editing /etc/resolv.conf manually doesn't persist through reboots, so my guess is it was done in this exercise just to illustrate the use of that file.

    I tried to dig into how DHCP is actually assigning the first DNS server and quickly got lost. You can see it getting assigned by dhclient if you run journalctl -u NetworkManager, but I agree with Babar that it's rather unclear *how* it's getting assigned.

    It quickly becomes muddied with the dhclient files, the files in /etc/NetworkManager, the files in /etc/sysconfig, and I also can't find a straight answer for how it works. Can someone explain this?

    PS - Babar, I hope some of the stuff I added helped you a little.

  • post-author-pic

    Thanks Jake :)  appreciate that 

Looking For Team Training?

Learn More