1

I've been scratching my head the whole day. I have the following netplan yaml file: (with mac address & ip addresses masked out for privacy)

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      match:
        macaddress: "aa:bb:cc:dd:ee:ff"
      set-name: enp2s0
      dhcp4: no
      addresses: [ "10.9.8.7/24" ]
      routes:
        - to: 0.0.0.0/0
          via: 10.9.8.8
          metric: 254
          table: 253
  vlans:
    vlan202:
      link: enp2s0
      id: 202
      addresses: [ 75.xxx.yyy.zzz/24 ]
      nameservers:
        addresses: [ 75.xxx.yyy.111, 75.75.75.75 ]
        search: [ example.org, example.com ]
      routes:
        - to: 0.0.0.0/0
          via: 75.xxx.yyy.100
          metric: 200
          table: 253

then I ran the command netplan try, make sure it doesn't have any errors then netplan generate. I then checked in /etc/systemd/network, it was empty, and I checked in /run/systemd/network, it has 2 files:

10-netplan-enp2s0.link:

[Match]
MACAddress=aa:bb:cc:dd:ee:ff

[Link]
Name=enp2s0
WakeOnLan=off

10-netplan-enp2s0.network:

[Match]
MACAddress=aa:bb:cc:dd:ee:ff
Name=enp2s0

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
DNS=10.9.8.8
Domains=lan

[DHCP]
UseMTU=true
RouteMetric=100
ClientIdentifier=mac
CriticalConnection=true

I though maybe it'll regenerate when I reboot the system, so I did, but the systemd config files still the same and complete ignore my custom settings. Am I doing something wrong or netplan is just a complete piece of garbage? that I should just go back to ifupdown?

  • 1
    It is not a complete piece of garbage, you haven't understood it very well. See netplan.io/reference – George Udosen Mar 20 at 8:00
  • Run networkctl status to see your configurations. – George Udosen Mar 20 at 8:06
  • maybe so. this is the first time i use netplan and yes i did went through netplan.io/reference (several times). I ran "netplan try", it didn't complain i have any errors. so why didn't it work? – Edwin Mar 20 at 8:17
  • and this is the out put of "networkctl status": State: routable Address: 10.9.8.225 on enp2s0 2603:xxxx::yyyy on enp2s0 2603:xxxx::zzzz on enp2s0 fd00:3024:1004::c16 on enp2s0 fd00:3024:1004:0:52e5:49ff:fe63:7469 on enp2s0 fe80::52e5:49ff:fe63:7469 on enp2s0 Gateway: 10.9,8.8 (NETGEAR) on enp2s0 fe80::2e30:33ff:fea0:c8db (NETGEAR) on enp2s0 DNS: 10.9.8.8 Search Domains: lan – Edwin Mar 20 at 8:19
  • what is the path you have installed this netplan yaml file to on the filesystem? – slangasek Mar 21 at 15:58
1

Looks like problem solved. It turns out there's an old .yaml file in /run/netplan that conflict with the one in /etc/netplan, once I deleted it, netplan apply works. (I never bother to check there since I rebooted the system many times and /run is mounted as tmpfs, how that .yaml file survive reboots is a mystery I guess).

Now next challenge:

How do I configure veth devices & netns in netplan?

0

netplan system-generated files under /run/netplan override your configuration under /etc/netplan. Your modifications to /run will not survive reboots.

From the netplan FAQ:

Alphabetically later files, no matter what directory in, will amend keys if the key does not already exist and override previous keys if they do.

To ensure that your configuration takes precedence, rename your files under /etc/netplan to place them lexically after enp2s0.yaml, e.g. zz-enp2s0.yaml.

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.