[Networkmanager] IPv6 and the loopback device /connection...

Ed V. evazquez at null-route.us
Wed Nov 8 23:50:08 UTC 2023


I have a use case where I need for the `lo` interface to respond on two 
specific IPv6 addresses.

This is for internal DNS resolution for a PiHole box, thus the local 
loopback use.

Right now, I can't get it working unless I manually add the IPv6 aliases 
using `ip addr' - and since dhclient isn't installed, using an exit-hook 
as I have in the past won't work either (unless I retro the system...).

System:

```$ uname -a
Linux raspberrypi 6.1.0-rpi6-rpi-v8 #1 SMP PREEMPT Debian 
1:6.1.58-1+rpt2 (2023-10-27) aarch64 GNU/Linux

$ NetworkManager --version
1.42.4 ```

Commands run to try and set this up:

$ sudo nmcli con mod lo +ipv4.addr "127.0.1.1/32, 127.0.1.2/32"
$ sudo nmcli con mod lo +ipv6.address "fde4:b3e2:db9e:5b10::1"
$ sudo nmcli con mod lo +ipv6.address "fde4:b3e2:db9e:5b10::2"

which created a file:

```$ sudo cat /etc/NetworkManager/system-connections/lo.nmconnection
[connection]
id=lo
uuid=e28dad0f-5e9b-4e49-86df-9252443dd185
type=loopback
autoconnect=false
interface-name=lo
timestamp=1699475696

[loopback]

[ipv4]
address1=127.0.0.1/8
address2=127.0.1.1/32
address3=127.0.1.2/32
method=manual

[ipv6]
addr-gen-mode=default
address1=::1/128
address2=fde4:b3e2:db9e:5b10::1/128
address3=fde4:b3e2:db9e:5b10::2/128
method=manual

[proxy]```

On reboot, I have:

```$ sudo nmcli -p dev show lo
===============================================================================
                               Device details (lo)
===============================================================================
GENERAL.DEVICE:                         lo
-------------------------------------------------------------------------------
GENERAL.TYPE:                           loopback
-------------------------------------------------------------------------------
GENERAL.HWADDR:                         00:00:00:00:00:00
-------------------------------------------------------------------------------
GENERAL.MTU:                            65536
-------------------------------------------------------------------------------
GENERAL.STATE:                          100 (connected (externally))
-------------------------------------------------------------------------------
GENERAL.CONNECTION:                     lo
-------------------------------------------------------------------------------
GENERAL.CON-PATH:                       
/org/freedesktop/NetworkManager/ActiveConnection/1
-------------------------------------------------------------------------------
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            --
-------------------------------------------------------------------------------
IP6.ADDRESS[1]:                         ::1/128
IP6.GATEWAY:                            --
-------------------------------------------------------------------------------

  $ sudo ip addr show lo
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
     inet6 ::1/128 scope host noprefixroute
        valid_lft forever preferred_lft forever```

Testing:

``` $ ping6 fde4:b3e2:db9e:5b10::1
PING fde4:b3e2:db9e:5b10::1(fde4:b3e2:db9e:5b10::1) 56 data bytes
^C
--- fde4:b3e2:db9e:5b10::1 ping statistics ---
8 packets transmitted, 0 received, 100% packet loss, time 7147ms
$ ping6 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.167 ms
64 bytes from ::1: icmp_seq=2 ttl=64 time=0.121 ms
64 bytes from ::1: icmp_seq=3 ttl=64 time=0.134 ms
^C
--- ::1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2055ms
rtt min/avg/max/mdev = 0.121/0.140/0.167/0.019 ms
$ ping 127.0.1.1
PING 127.0.1.1 (127.0.1.1) 56(84) bytes of data.
64 bytes from 127.0.1.1: icmp_seq=1 ttl=64 time=0.138 ms
64 bytes from 127.0.1.1: icmp_seq=2 ttl=64 time=0.157 ms
^C
--- 127.0.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1021ms
rtt min/avg/max/mdev = 0.138/0.147/0.157/0.009 ms```

So IPv4 works as expected, but IPv6 does not.

All that, but as soon as I use the `ip` command, it works.

'''$ sudo /sbin/ip -6 addr add fde4:b3e2:db9e:5b10::1 dev lo
$ sudo /sbin/ip -6 addr add fde4:b3e2:db9e:5b10::2 dev lo
$ ping6 PING fde4:b3e2:db9e:5b10::1(fde4:b3e2:db9e:5b10::1) 56 data 
bytes
64 bytes from fde4:b3e2:db9e:5b10::1: icmp_seq=1 ttl=64 time=0.167 ms
64 bytes from fde4:b3e2:db9e:5b10::1: icmp_seq=2 ttl=64 time=0.121 ms
64 bytes from fde4:b3e2:db9e:5b10::1: icmp_seq=3 ttl=64 time=0.134 ms
^C
--- fde4:b3e2:db9e:5b10::1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2055ms
rtt min/avg/max/mdev = 0.121/0.140/0.167/0.019 ms```

Any ideas on how to get this working?

--
Ed V.


More information about the Networkmanager mailing list