2

system ip configuration b4 netplan edit:

root@pro-rpi-02:/# ip a sh
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:b3:45:e0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.2/26 brd 192.168.1.63 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.1.7/26 brd 192.168.1.63 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::4569:7d7a:108d:c2ad/64 scope link
       valid_lft forever preferred_lft forever

I've added a vlan to the netplan:

root@pro-rpi-02:/# more /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.2/26
      gateway4: 192.168.1.10
      nameservers:
          addresses: [192.168.1.24]
          search: [hello.home]
  vlans:
    vlan.8:
      id: 8
      link: eth0
      dhcp4: no
      addresses:
        - 192.168.8.2/24

And now the fun part:

root@pro-rpi-02:/cluster/Radius# ip addr sh
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:b3:45:e0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.2/26 brd 192.168.1.63 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.1.5/26 brd 192.168.1.63 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::4569:7d7a:108d:c2ad/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether dc:a6:32:b3:45:e1 brd ff:ff:ff:ff:ff:ff
4: vlan.8@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether dc:a6:32:b3:45:e0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.2/24 brd 192.168.8.255 scope global vlan.8
       valid_lft forever preferred_lft forever
    inet 192.168.8.112/24 brd 192.168.8.255 scope global secondary noprefixroute vlan.8
       valid_lft forever preferred_lft forever

Anyone can explain why I'm getting the dhcp address 192.168.8.112/24 ? Or at least let me know where I can start looking?

root@pro-rpi-02:/# netplan --debug generate
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:750570): DEBUG: 12:17:28.037: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:750570): DEBUG: 12:17:28.038: starting new processing pass
** (generate:750570): DEBUG: 12:17:28.038: We have some netdefs, pass them through a final round of validation
** (generate:750570): DEBUG: 12:17:28.038: eth0: setting default backend to 1
** (generate:750570): DEBUG: 12:17:28.038: Configuration is valid
** (generate:750570): DEBUG: 12:17:28.038: vlan.8: setting default backend to 1
** (generate:750570): DEBUG: 12:17:28.039: Configuration is valid
** (generate:750570): DEBUG: 12:17:28.040: Generating output files..
** (generate:750570): DEBUG: 12:17:28.040: openvswitch: definition eth0 is not for us (backend 1)
** (generate:750570): DEBUG: 12:17:28.040: NetworkManager: definition eth0 is not for us (backend 1)
** (generate:750570): DEBUG: 12:17:28.040: openvswitch: definition vlan.8 is not for us (backend 1)
** (generate:750570): DEBUG: 12:17:28.040: NetworkManager: definition vlan.8 is not for us (backend 1)

UPDATE 1, as requested, here is the output, stil don't see anything which could help me here :)

root@pro-rpi-02:~# networkctl --full --all --no-pager status
● 1: lo
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: n/a
                          Type: loopback
                         State: carrier (unmanaged)
                           MTU: 65536
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 1/1
                       Address: 127.0.0.1

● 2: eth0
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /run/systemd/network/10-netplan-eth0.network
                          Type: ether
                         State: routable (failed)
                          Path: platform-fd580000.ethernet
                        Driver: bcmgenet
                    HW Address: dc:a6:32:b3:45:e0 (Raspberry Pi Trading Ltd)
                           MTU: 1500 (min: 68, max: 1500)
                         QDisc: mq
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 5/5
              Auto negotiation: yes
                         Speed: 1Gbps
                        Duplex: full
                          Port: mii
                       Address: 192.168.1.2
                                192.168.1.5
                                192.168.1.7
                                fe80::4569:7d7a:108d:c2ad
                       Gateway: 192.168.1.10
                           DNS: 192.168.1.24
                Search Domains: hello.home
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab112ca77a819cd16ac00000

Mar 10 22:03:14 pro-rpi-02 systemd-networkd[926]: eth0: IPv6 successfully enabled
Mar 10 22:03:14 pro-rpi-02 systemd-networkd[926]: eth0: Link UP
Apr 19 16:51:22 pro-rpi-02 systemd-networkd[926]: eth0: Gained carrier
Apr 19 16:51:24 pro-rpi-02 systemd-networkd[926]: eth0: Gained IPv6LL
Apr 20 16:32:48 pro-rpi-02 systemd-networkd[926]: eth0: DHCPv6 lease lost
Apr 20 16:32:48 pro-rpi-02 systemd-networkd[672911]: eth0: Gained IPv6LL
Apr 20 16:32:48 pro-rpi-02 systemd-networkd[672911]: eth0: IPv6 successfully enabled
Apr 20 16:32:48 pro-rpi-02 systemd-networkd[672911]: eth0: Could not set route: Nexthop has invalid gateway. Network is unreachable
Apr 20 16:32:48 pro-rpi-02 systemd-networkd[672911]: eth0: Failed

● 3: wlan0
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: n/a
                          Type: wlan
                         State: no-carrier (unmanaged)
                          Path: platform-fe300000.mmcnr
                        Driver: brcmfmac
                    HW Address: dc:a6:32:b3:45:e1 (Raspberry Pi Trading Ltd)
                           MTU: 1500 (min: 68, max: 1500)
                         QDisc: fq_codel
  IPv6 Address Generation Mode: none
          Queue Length (Tx/Rx): 1/1

Apr 19 16:51:22 pro-rpi-02 systemd-networkd[926]: wlan0: Link UP

● 4: vlan8
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /run/systemd/network/10-netplan-vlan8.network
                          Type: vlan
                         State: routable (configuring)
                        Driver: 802.1Q VLAN Support
                    HW Address: dc:a6:32:b3:45:e0 (Raspberry Pi Trading Ltd)
                           MTU: 1500 (max: 65535)
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
                       VLan Id: 8
          Queue Length (Tx/Rx): 1/1
              Auto negotiation: yes
                         Speed: 1Gbps
                        Duplex: full
                          Port: mii
                       Address: 192.168.8.2
                                192.168.8.112
                       Gateway: 192.168.8.10
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab112ca77a819cd16ac00000

Apr 20 16:32:48 pro-rpi-02 systemd-networkd[672911]: vlan8: netdev ready
Apr 20 16:32:49 pro-rpi-02 systemd-networkd[672911]: vlan8: Link UP
Apr 20 16:32:49 pro-rpi-02 systemd-networkd[672911]: vlan8: Gained carrier
Apr 20 16:32:49 pro-rpi-02 systemd-networkd[672911]: vlan8: IPv6 successfully enabled
2
  • I had to revert the change, as the fact that DHCP is pushing the data to my RPI is breaking my cluster. Therefore the name of the vlan interface isn't vlan.8 but vlan8, so just the "." is missing. Didn't change anything, but just letting you know about this :) Also noticed that removing entries from the netplan and giving them a "netplan try", will leave the RPI unreachable. Assuming that the cleanup process isn't working correcty.
    – Shio
    Commented Apr 20, 2021 at 14:44
  • Could it simply be that a latter config is overwriting the 01-* config? askubuntu.com/a/1339098
    – Ben
    Commented Feb 12 at 18:46

2 Answers 2

2

After spending X amount of hours on trying to find the fix here, I decided to just disable the dhcpcd service:

root@pro-rpi-02:~# systemctl status dhcpcd.service
● dhcpcd.service - DHCP Client Daemon
     Loaded: loaded (/lib/systemd/system/dhcpcd.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:dhcpcd(8)

Now everything is working like I would like it to work:

root@pro-rpi-02:~# more /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses:
        - 192.168.1.2/26
      gateway4: 192.168.1.10
      nameservers:
          addresses: [192.168.1.24]
          search: [hello.home]
  vlans:
    vlan8:
      id: 8
      link: eth0
      dhcp4: no
      dhcp6: no
      addresses:
        - 192.168.8.2/24
root@pro-rpi-02:~# ip a sh vlan8
4: vlan8@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether dc:a6:32:b3:45:e0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.2/24 brd 192.168.8.255 scope global vlan8
       valid_lft forever preferred_lft forever
    inet6 fe80::dea6:32ff:feb3:45e0/64 scope link
       valid_lft forever preferred_lft forever
1
  • OMG thanks. This has been driving me bananas for a whole day. Commented Jan 7, 2023 at 11:02
1

For the record I hit a similar problem with IPv6, as I upgraded from Ubuntu 18.04 to 20.04 and netplan I noticed that I now had two IPv6 addresses:

  1. The automatic DHCP? one 2001:19f0:6801:1dc3:5400:3ff:feeb:abea
  2. The custom one I statically choose 2001:19f0:6801:1dc3::1
> ip addr
[...]
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 56:00:03:eb:ab:ea brd ff:ff:ff:ff:ff:ff
    inet 217.69.14.107/23 brd 217.69.15.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 2001:19f0:6801:1dc3:5400:3ff:feeb:abea/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 2591957sec preferred_lft 604757sec
    inet6 2001:19f0:6801:1dc3::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::5400:3ff:feeb:abea/64 scope link 
       valid_lft forever preferred_lft forever
> curl ifconfig.io
2001:19f0:6801:1dc3:5400:3ff:feeb:abea

And the DHCP one is first so it's used by default which is not what I want (I want the shorter custom IPv6 to be used).

I tried disabling dhcp6 with dhcp6: no but the DHCP address was always present... I also didn't find an easy way to change order to have the custom one first. After a lot of trial and error, I found that this was caused by the "Router Advertisement" and not by DHCP apparently, so I had to disable this with accept-ra: no, and set the default route manually as this is also configured by Router Advertisement.

My final config file looks like:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: yes
      accept-ra: no # otherwise we get auto IPv6 too
      addresses: ['2001:19f0:6801:1dc3::1/64']
      gateway6: fe80::fc00:3ff:feeb:abea

(note that I don't speficy any nameserver here because I am running a local resolver but you may have to)

And with I finally have only my custom IPv6 and it's working fine:

> ip addr
[...]
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 56:00:03:eb:ab:ea brd ff:ff:ff:ff:ff:ff
    inet 217.69.14.107/23 brd 217.69.15.255 scope global dynamic enp1s0
       valid_lft 86397sec preferred_lft 86397sec
    inet6 2001:19f0:6801:1dc3::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::5400:3ff:feeb:abea/64 scope link 
       valid_lft forever preferred_lft forever
> curl ifconfig.io
2001:19f0:6801:1dc3::1
1
  • Thank you for the write up, exactly what I needed. +1 :)
    – robetus
    Commented Apr 19, 2023 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .