You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Look at the current systemd-networkd configuration
$ ls -1 /etc/netplan/
50-cloud-init.yaml
$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes# to it will not persist across an instance reboot. To disable cloud-init's# network configuration capabilities, write a file# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: true
dhcp6: false
match:
macaddress: 02:8c:6e:21:a0:88
set-name: eth0
version: 2
$ journalctl -b -u systemd-networkd
...
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /run/systemd/network/10-netplan-eth0.network, because it's not a regular file with suffix .netdev.Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /run/systemd/network/10-netplan-eth0.link, because it's not a regular file with suffix .netdev.
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /lib/systemd/network/80-container-vz.network, because it's not a regular file with suffix .netdev.Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /lib/systemd/network/80-container-host0.network, because it's not a regular file with suffix .netdev.
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /lib/systemd/network/80-container-ve.network, because it's not a regular file with suffix .netdev.Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .netdev.
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /run/systemd/network/10-netplan-eth0.link, because it's not a regular file with suffix .network.Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .network.
...
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: eth0: Link state is up-to-date
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: eth0: found matching network '/run/systemd/network/10-netplan-eth0.network'
Jul 05 06:14:21 ip-172-31-27-173 systemd-networkd[23077]: eth0: IPv6 successfully enabled
...
$ ls -1 /run/systemd/network
10-netplan-eth0.link
10-netplan-eth0.network
$ ls -1 /lib/systemd/network
80-container-host0.network
80-container-ve.network
80-container-vz.network
99-default.link
$ systemd-resolve --status
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 3 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (eth0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 172.31.0.2
DNS Domain: eu-central-1.compute.internal
Disable DNS servers from DHCP
All configuration files in /lib/systemd/network, /run/systemd/network, /etc/systemd/network are collectively sorted and processed in lexical order, regardless of the directories in which they live
We need to create .network file for eth0 in /etc/systemd/network with the name of lexical order priority
$ ls -1 /etc/systemd/network
$ sudo cat > /etc/systemd/network/09-static-dns-eth0.network <<_EOF[Match]MACAddress=02:8c:6e:21:a0:88Name=eth0[Network]DHCP=ipv4LinkLocalAddressing=ipv6[DHCP]UseDNS=falseRouteMetric=100UseMTU=true_EOF
$ journalctl -b -u systemd-networkd
...
Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /etc/systemd/network/09-static-dns-eth0.network, because it's not a regular file with suffix .netdev.Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /run/systemd/network/10-netplan-eth0.network, because it's not a regular file with suffix .netdev.
Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /run/systemd/network/10-netplan-eth0.link, because it's not a regular file with suffix .netdev.Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /lib/systemd/network/80-container-vz.network, because it's not a regular file with suffix .netdev.
Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /lib/systemd/network/80-container-host0.network, because it's not a regular file with suffix .netdev.Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /lib/systemd/network/80-container-ve.network, because it's not a regular file with suffix .netdev.
Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .netdev.Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /run/systemd/network/10-netplan-eth0.link, because it's not a regular file with suffix .network.
Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: Ignoring /lib/systemd/network/99-default.link, because it's not a regular file with suffix .network....Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: eth0: Link state is up-to-dateJul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: eth0: found matching network '/etc/systemd/network/09-static-dns-eth0.network'Jul 05 06:46:23 ip-172-31-27-173 systemd-networkd[23391]: eth0: IPv6 successfully enabled...
$ systemd-resolve --status
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 3 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (eth0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Domain: eu-central-1.compute.internal
Look at the current systemd-resolved configuration
$ cat /etc/systemd/resolved.conf
# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.## Entries in this file show the compile time defaults.# You can change settings by editing this file.# Defaults can be restored by simply deleting this file.## See resolved.conf(5) for details
[Resolve]
#DNS=#FallbackDNS=#Domains=#LLMNR=no#MulticastDNS=no#DNSSEC=no#Cache=yes#DNSStubListener=yes
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.## This is a dynamic resolv.conf file for connecting local clients to the# internal DNS stub resolver of systemd-resolved. This file lists all# configured search domains.## Run "systemd-resolve --status" to see details about the uplink DNS servers# currently in use.## Third party programs must not access this file directly, but only through the# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,# replace this symlink by a static file or a different symlink.## See man:systemd-resolved.service(8) for details about the supported modes of# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search eu-central-1.compute.internal
$ cat > /etc/systemd/resolved.conf <<_EOF# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.## Entries in this file show the compile time defaults.# You can change settings by editing this file.# Defaults can be restored by simply deleting this file.## See resolved.conf(5) for details[Resolve]DNS=8.8.8.8 1.1.1.1#FallbackDNS=#Domains=#LLMNR=no#MulticastDNS=no#DNSSEC=no#Cache=yes#DNSStubListener=yes_EOF
Look at the changed systemd-resolved configuration
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-resolved # !!! HERE is systemd-resolved ... NOT systemd-networkd
$ systemd-resolve --status
Global
DNS Servers: 8.8.8.8
1.1.1.1
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 3 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (eth0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Domain: eu-central-1.compute.internal
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.## This is a dynamic resolv.conf file for connecting local clients to the# internal DNS stub resolver of systemd-resolved. This file lists all# configured search domains.## Run "systemd-resolve --status" to see details about the uplink DNS servers# currently in use.## Third party programs must not access this file directly, but only through the# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,# replace this symlink by a static file or a different symlink.## See man:systemd-resolved.service(8) for details about the supported modes of# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search eu-central-1.compute.internal