1

I have an Odroid C2 - a single board computer running 18.04 minimal for ARM. Originally, it was using NetworkManager + systemd-resolved to manage network connections, but since I use only Ethernet and always connected to the same network, I find it a little bit overkill, so I disable both of them and moved to Netplan. Here is my /etc/netplan/02-networkd.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes

As you can see, it is a simple DHCP configuration. Here is the result of using that config:

# netplan ip leases eth0
ADDRESS=10.0.0.4
NETMASK=255.255.255.0
ROUTER=10.0.0.1
SERVER_ADDRESS=10.0.0.1
T1=7200
T2=12600
LIFETIME=14400
DNS=10.0.0.1
NTP=10.0.0.1
DOMAINNAME=vault
CLIENTID=fff75f76ac00020000ab11a7b5e398b7e20ac7

IP address and all interface parameters set correct. The only problem I have is with DNS. I found that netplan does not update /etc/resolve.conf even it has all obligatory information in the leas.

Is there a way to make Netplane update/configure /etc/resolve.conf with DNS information it receives from DHCP without using NetworkManager or resolved? Here is some additional info:

# ls -lA /etc/resolv.conf
-rw-r--r-- 1 root root 20 Apr 21 00:13 /etc/resolv.conf

# cat /etc/resolv.conf 
nameserver 10.0.0.1
search vault
  • Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl (or system-resolve --status). Start comments to me with @heynnema or I may miss them. – heynnema Apr 20 at 20:20
  • @heynnema current resolv.conf is just a regular hand-written file. It seems that this installation is missing both resolvectl and system-resolve. – e-pirate Apr 20 at 21:19
  • Oops. A typo by me. The correct command is systemd-resolve --status. Give me a couple of minutes to put together a quick answer for you. Are you using VPN? – heynnema Apr 20 at 21:25
  • @heynnema the systemd-resolved is down, my question is how to make netplan manage resolve.conf without external services like resolved and NetworkManager. – e-pirate Apr 20 at 21:45
  • Did you disable systemd-resolved? I just looked back and I see that you did. That and/or dnsmasq manage DNS, and /etc/resolv.conf. – heynnema Apr 20 at 21:54
0

It is a deliberate design decision that netplan delegates management of resolver configuration to systemd-resolved. There is no support in netplan for directly managing /etc/resolv.conf based on answers to dhcp queries. Indeed, systemd-networkd expects to pass this information to systemd-resolved and netplan relies on this behavior.

  • So, I need a whole service just to maintain a single file in up to date state? Why? – e-pirate Apr 20 at 19:22
  • The function of systemd-resolved is not to maintain /etc/resolv.conf. The function of systemd-resolved is to make it unnecessary to maintain /etc/resolv.conf, because having a resolv.conf file that changes makes name resolution unreliable across the life cycle of a system (especially for e.g. long-lived chroots, containers, etc), and also a local resolver is capable of detecting when an upstream nameserver is down and provide better behavior when compared with the in-process glibc behavior. – slangasek Apr 22 at 1:26
0

I see it a lot. Users have removed the symlink for /etc/resolv.conf, and put a hand-written file there. There's actually three different places that this symlink refers to, and I'll give you the most common one...

In terminal...

cd /etc # change directory

sudo mv resolv.conf resolv.conf.BAK # rename the current resolv.conf as a backup file

sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf # recreate standard symlink

Note: do not manually edit /etc/resolv.conf!

  • systemd-resolved mast be up for the method, while I want to get rid of any 'external' services and make netplan manage resolev.conf by itself. – e-pirate Apr 20 at 21:49
  • @e-pirate doesn't work that way... and... you use dhcp4, so you do rely on external services now. – heynnema Apr 20 at 21:55
  • DHCP client is a mast-have in that chain, as well as something to handle interface configuration on the client side, while resolved is just a mediator between dhcp and resolv.conf. In Gentoo I don't need any external service to the system, that manages network interfaces (ipupdown AFAIR), it will write data from dhcp lease to resolv.conf. I expected netplan to handle that, but it seems that netplan needs an external DNS handler like resolved. – e-pirate Apr 20 at 22:11
0

Have you tried static settings

A simple edit to /etc/NetworkManager/NetworkManager.conf and disabling systemd-resolved.service(as in this answer https://askubuntu.com/a/907249/719422). But that alone, while essential, does not guarantee tamper-proof resolv.conf.

do this as SuperUser:

echo nameserver 8.8.8.8 > /etc/resolv.conf chattr -e /etc/resolv.conf chattr +i /etc/resolv.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.