0

TL;DR

Does anyone have a working netplan configuration that sets a dynamic IPv4 and a static IPv6 under Ubuntu Server 20.04?

What works

My provider (OVH) gave me a server with this configuration in /etc/netplan/50-cloud-init.yaml out of the box:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        ens3:
            dhcp4: true
            match:
                macaddress: xx:yy:zz:aa:bb:cc
            mtu: 1500
            set-name: ens3

So the server is obtaining an IPv4 address through DHCP. Everything works here.

The issue

But, they also gave a static IPv6 (found from the web console management for this server) which is not present in the netplan configuration. I tried to add it manually, using snippet like:

network:
    version: 2
    ethernets:
        ens3:
            dhcp6: false
            match:
                name: ens3
            addresses:
              - "dead:beef:404:200::cafe/128"
            gateway6: "dead:beef:404:200::1"

But nothing works: if the IPv4 works I have no IPv6, and if I get an IPv6 it revokes my IPv4 and I lose access to the server.

The try

I just tried this exact configuration in /etc/netplan/60-test-askubuntu.yaml after renamed all other files with .yaml.bak:

network:
    version: 2
    ethernets:
        ens3:
            dhcp6: false
            addresses:
              - "2001:41d0:206:cd1d::6153/128"
            gateway6: "2001:41d0:206:cd1d::1"
            dhcp4: true
            mtu: 1500

Result: the IPv4 is still working but I guess it will fail when the DHCP bail will be expired. The IPv6 address is set, but the gateway is not set so I cannot ping6 an IPv6 address:

user@server:/etc/netplan$ ip a
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 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether fa:16:3e:23:28:1f brd ff:ff:ff:ff:ff:ff
    inet 51.210.xx.yy/32 scope global dynamic ens3
       valid_lft 86396sec preferred_lft 86396sec
    inet6 2001:41d0:206:cd1d::6153/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe23:281f/64 scope link 
       valid_lft forever preferred_lft forever
user@server:/etc/netplan$ ip route
default via 51.210.8.1 dev ens3 proto dhcp src 51.210.xx.yy metric 100 
51.210.8.1 dev ens3 proto dhcp scope link src 51.210.xx.yy metric 100 
user@server:/etc/netplan$ ping google.com
PING google.com (172.217.22.142) 56(84) bytes of data.
64 bytes from par21s12-in-f14.1e100.net (172.217.22.142): icmp_seq=1 ttl=51 time=6.16 ms
64 bytes from par21s12-in-f14.1e100.net (172.217.22.142): icmp_seq=2 ttl=51 time=6.19 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.161/6.177/6.194/0.016 ms
user@server:/etc/netplan$ ping6 google.com
ping6: connect: Network is unreachable
user@server:/etc/netplan$ ip route
default via 51.210.8.1 dev ens3 proto dhcp src 51.210.xx.yy metric 100 
51.210.8.1 dev ens3 proto dhcp scope link src 51.210.xx.yy metric 100 
user@server:/etc/netplan$ ip -6 route
::1 dev lo proto kernel metric 256 pref medium
2001:41d0:206:cd1d::6153 dev ens3 proto kernel metric 256 pref medium
fe80::/64 dev ens3 proto kernel metric 256 pref medium

Question

Does anyone have a working netplan configuration for a dynamic IPv4 and a static IPv6?

It works when I set it manually using ip addr and ip route but I want a permanent configuration using netplan.

Thanks!

  • when you say you added it manually, what is the structure of /etc/netplan now? Have you added this under a second file, and with what name? How are you applying the configuration to your system? – slangasek May 10 at 20:19
  • Just as a note, the 'match: name: ens3' should be completely unnecessary. – slangasek May 10 at 20:19
  • Thanks, @slangasek. I directly replied in my question by adding the section "the try". – yaap May 11 at 21:21
0

I finally found my answer on this post: https://community.ovh.com/t/vps-en-ipv6-gateway/28984/5

The correct configuration (for this particular situation) is:

network:
    version: 2
    ethernets:
        ens3:
            dhcp4: true
            dhcp6: false
            match:
                macaddress: fa:16:3e:33:8d:59
            set-name: ens3
            addresses:
              - 2402:1f00:8100:400:0:0:0:c1/128
            gateway6: 2402:1f00:8100:0400:0000:0000:0000:0001
            routes:
              - to: 2402:1f00:8100:0400:0000:0000:0000:0001
                scope: link

I don't understand why, but the routes section is needed for netplan to apply a new IPv6 route. gateway6 is not enough.

| improve this answer | |

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.