Networking – Fix Debian Ignoring Static IPv6 Configuration

ipiprouteipv6network-interfacenetworking

Original post

I'm trying to configure a static IPv6 address for my Debian container (running on LXD) but the system keeps ignoring my configuration.

Currently my /etc/network/interfaces looks like this:

auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp

auto eth1
iface eth1 inet static
    address 10.1.0.10/16
    gateway 10.1.0.1
iface eth1 inet6 static
    address fd01::10/64
    gateway fd01::1
    autoconf 0

The static IPv4 configuration and the DHCP option for IPv6 (on eth0) work fine as the command ip addr shows:

76: eth0@if77: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:53:50:bc brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.10/16 brd 10.0.255.255 scope global dynamic eth0
       valid_lft 84286sec preferred_lft 84286sec
    inet6 fd00::10/128 scope global
       valid_lft forever preferred_lft forever
78: eth1@if79: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:83:c3:49 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.1.0.10/16 brd 10.1.255.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fd01::658:fe25:52de:cc45/64 scope global dynamic mngtmpaddr
       valid_lft 3372sec preferred_lft 3372sec

But my system constantly keeps ignoring the static IPv6 configuration part and always generates it's own dynamic IPv6 address instead of using the preconfigured one. The output above also says that the ip address on this interface was generated dynamically.

But if I set the static IPv6 address with the command ip addr add fd01::10/64 dev eth1 it works but that's not an appropriate and permanent solution for this problem.

Edits

(1) systemd network manager

The command networkctl list returns the following output:

IDX LINK     TYPE     OPERATIONAL SETUP
 WARNING: systemd-networkd is not running, output will be incomplete.
 (...)
 16 eth0     ether    n/a         unmanaged
 18 eth1     ether    n/a         unmanaged
 (...)

I think that this means that the systemd network manager is disabled.

(2) /etc/init.d/networking

After rebooting the container and fetching the log of the /etc/init.d/networking service with systemctl status networking.service the following message is displayed

● networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2020-02-08 00:22:06 UTC; 1min 31s ago
       Docs: man:interfaces(5)
    Process: 31 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
   Main PID: 31 (code=exited, status=1/FAILURE)

Feb 08 00:22:06 Core dhclient[112]: message status code Success: "all addresses still on link"
Feb 08 00:22:06 Core ifup[137]: RTNETLINK answers: File exists
Feb 08 00:22:06 Core ifup[31]: ifup: failed to bring up eth1
Feb 08 00:22:06 Core systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Feb 08 00:22:06 Core systemd[1]: networking.service: Failed with result 'exit-code'.
Feb 08 00:22:06 Core systemd[1]: Failed to start Raise network interfaces.

If I configure eth0 to use a static IPv6 address, the error also rises for eth0.
I found this error message by following this tutorial to configure a static IPv6 address.

(3) Host system

One thing I didn't thought about at first is that the problem could be related to my host operating system. Because of that I didn't wrote that my host system is Gentoo with a customized kernel.
At the moement I haven't solved my problem at all but a test with the same setup on another host (this time ArchLinux) worked fine. Because the configuration is actually the same but the host system is different I think my problem is related to a configuration error on my host system (e.g. I must enable another kernel feature).

I didn't use exactly the same configuration. My normal host (Gentoo) uses Debian 10 and my ArchLinux test machine used Debian 11. When using Debian 11 on my Gentoo host it works fine. But also if I create a new container with Debian 10 the ip configuration works as expected.

Best Answer

Finally I solved my problem through changing the order of my entries in my /etc/network/interfaces file. Now it looks like that:

auto eth1
iface eth1 inet static
    address 10.1.0.10/16
    gateway 10.1.0.1
iface eth1 inet6 static
    address fd01::10/64
    gateway fd01::1

auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp

If the static entries are configured first, everything works fine.

Related Question