My yaml file is:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      dhcp4: no
      dhcp6: no
    enp3s0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.245.50/24]
  bridges:
    br0:
      interfaces: [enp2s0]
      dhcp4: no
      dhcp6: no
      addresses: [192.168.204.35/24]
      nameservers:
        addresses: [192.168.1.4,192.168.1.5]
        search: [mydomain.xyz]
        routes:
          - to: 0.0.0.0/0
            via: 192.168.204.1
            metric: 200
            type: unicast

After 'netplan apply' command i get the wrong route mask (0.0.0.0/24):

$ sudo ip route
0.0.0.0/24 via 192.168.204.1 dev br0 proto static metric 200 linkdown 
169.254.0.0/16 dev enp3s0 scope link metric 1000 
192.168.204.0/24 dev br0 proto kernel scope link src 192.168.204.35 metric 425 linkdown 
192.168.245.0/24 dev enp3s0 proto kernel scope link src 192.168.245.50 metric 100
$ sudo ip route del 0.0.0.0/24
$ sudo ip route add 0.0.0.0/0 via 192.168.204.1 dev br0 proto static metric 200
$ sudo ip route
default via 192.168.204.1 dev br0 proto static metric 200 
....

When I specify the correct route (see above), the interface goes up and the network becomes available. After reboot the wrong route appears again.

What to do?

  • You have to do a sudo netplan --debug generate before the sudo netplan apply. But you probably should be using networkd instead of NetworkManager. Is this a server? Report back to @heynnema – heynnema Oct 26 at 15:15
  • Hi, @heynnema! I use desktop version. Execution of sudo netplan --debug generate before the sudo netplan apply don't take effect. @Yuri Fedkin – Yuri Fedkin Oct 29 at 7:19

Notes:

Check the gateway4 address and DNS nameserver/search values that I used. I'm not sure if having them on different subnets from the main IP addresses will cause DNS resolution errors.

If you don't need the bridge, you can move the addresses: and routes: stanza's directly into enp2s0 (under dhcp6), and remove the bridges: section. Be mindful of the indentation.

If you copy/paste the script, you may need to remove the leading 4 spaces from each line. This is because when I use the {} code sample to make the script readable, it adds 4 spaces to the beginning of each line. Keep the indentation the same.

If you don't have any wireless interfaces, you may need to change NetworkManager to networkd.

Use https://netplan.io/examples for more examples.

After installing the script (as the only .yaml file) into /etc/netplan do:

sudo netplan --debug generate

sudo netplan apply

reboot


network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      dhcp4: no
      dhcp6: no
      nameservers:
        addresses: [192.168.1.4,192.168.1.5]
        search: [mydomain.xyz]
      optional: true
    enp3s0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.245.50/24]
      gateway4: 192.168.245.1
      nameservers:
        addresses: [192.168.1.4,192.168.1.5]
        search: [mydomain.xyz]
      optional: true
  bridges:
    br0:
      interfaces: [enp2s0]
      addresses: [192.168.204.35/24]
      routes:
        - to: 0.0.0.0/0
          via: 192.168.204.1
          metric: 200
          type: unicast
  • Hi, @heynnema! When I apply your yaml script and reboot PC I've got linkdown state for br0 interface and 0.0.0.0/24 as default route. – Yuri Fedkin Oct 30 at 13:37
  • Do you have wireless networks on this machine? Did you remove the leading 4 spaces from each line, if that was required? Did you keep the indentation the same? Did the generate command issue any errors? – heynnema Oct 30 at 13:43
  • I think that this problem lies in NetworkManager area. Wheh I run nm-connection-editor choose br0 interface and click on routes button on IPv4-tab I see error on route. The cell with address 0.0.0.0 is marked with red color and mask is set to 255.255.255.0. When i try to correct mask to 0.0.0.0 the cell becames red, too. – Yuri Fedkin Oct 30 at 13:48
  • I haven't any wi-fi interface. As you see above I follow to indent recomendations. – Yuri Fedkin Oct 30 at 13:50
  • @YuriFedkin first, try changing NetworkManager to networkd, redo the two netplan commands, and see if that helps. Second, if that doesn't help, you can try moving the addresses and routes from br0 to enp2s0, right under the dhcp6 line. Report back, and I can edit the answer if either change works. – heynnema Oct 30 at 13:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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