Docker Community Forums

Share and learn in the Docker community.

Default route changed after dual stack (ipv4 and ipv6) docker vlan network creation and connection

I use an ubuntu 18.04 docker container on ubuntu 18.04 host.
When I create a new dual stack (ipv4 and ipv6) docker vlan network from container and connect it into same running container default route changed.
So I’ve some problem because some running service into container need that default route is “default via 172.30.0.1 dev eth0”.

Can you help me ?


BEGIN STATUS AFTER CONTAINER START

user@ubuntu:~$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
592: eth0@if593: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 172.30.0.2/24 brd 172.30.0.255 scope global eth0
       valid_lft forever preferred_lft forever
user@ubuntu:~$ 
user@ubuntu:~$ ip -6 addr
user@ubuntu:~$ 
user@ubuntu:~$ ip -4 route
default via 172.30.0.1 dev eth0
172.30.0.0/24 dev eth0 proto kernel scope link src 172.30.0.2 
user@ubuntu:~$ 
user@ubuntu:~$ ip -6 route
user@ubuntu:~$ 

ADD VLAN IPV4 AND IPV6

user@ubuntu:~$ docker network create -d macvlan -o parent=enp1s0 --subnet=10.0.0.0/24 --ipv6 --subnet=2020:db8:2222::/64 test_vlan
a75b1cc33f50ccedb022b6698311c7485bfa708ddf5881e80025b6789fcc9bf3
user@ubuntu:~$ docker network connect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ 
user@ubuntu:~$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
592: eth0@if593: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 172.30.0.2/24 brd 172.30.0.255 scope global eth0
       valid_lft forever preferred_lft forever
594: eth1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 10.0.0.2/24 brd 10.0.0.255 scope global eth1
       valid_lft forever preferred_lft forever
user@ubuntu:~$ ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
594: eth1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP 
    inet6 2020:db8:2222::2/64 scope global nodad 
       valid_lft forever preferred_lft forever
    inet6 fe80::42:aff:fe00:2/64 scope link 
       valid_lft forever preferred_lft forever
user@ubuntu:~$ 
user@ubuntu:~$ ip -4 route
default via 10.0.0.1 dev eth1 
10.0.0.0/24 dev eth1 proto kernel scope link src 10.0.0.2 
172.30.0.0/24 dev eth0 proto kernel scope link src 172.30.0.2 
user@ubuntu:~$ 
user@ubuntu:~$ ip -6 route
2020:db8:2222::/64 dev eth1 proto kernel metric 256 pref medium
3000::11 dev eth1 proto kernel metric 256 expires 2591968sec pref medium
fe80::/64 dev eth1 proto kernel metric 256 pref medium
default via 2020:db8:2222::1 dev eth1 metric 1024 pref medium
default via fe80::2d0:d6ff:fe54:5565 dev eth1 proto ra metric 1024 expires 1768sec pref medium
user@ubuntu:~$ 
user@ubuntu:~$ 
user@ubuntu:~$ docker network disconnect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ docker network rm test_vlan
test_vlan

ADD VLAN ONLY IPV4

user@ubuntu:~$ docker network create -d macvlan -o parent=enp1s0 --subnet=10.0.0.0/24 test_vlan
e76d9fb654a7fa622e7f5159b440a3d86fb0863862a1fd19c0898ece51e260f1
user@ubuntu:~$ docker network connect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ 
user@ubuntu:~$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
592: eth0@if593: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 172.30.0.2/24 brd 172.30.0.255 scope global eth0
       valid_lft forever preferred_lft forever
595: eth2@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 10.0.0.2/24 brd 10.0.0.255 scope global eth2
       valid_lft forever preferred_lft forever
user@ubuntu:~$ ip -6 addr
user@ubuntu:~$ ip -4 route
default via 172.30.0.1 dev eth0 
10.0.0.0/24 dev eth2 proto kernel scope link src 10.0.0.2 
172.30.0.0/24 dev eth0 proto kernel scope link src 172.30.0.2 
user@ubuntu:~$ ip -6 route
user@ubuntu:~$ 
user@ubuntu:~$ docker network disconnect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ docker network rm test_vlan
test_vlan

ADD VLAN ONLY IPV6

user@ubuntu:~$ docker network create -d macvlan -o parent=enp1s0 --ipv6 --subnet=2020:db8:2222::/64 test_vlan
38e38a66740fd99f3b0fb61dd414d8309ed501256b0abc66a3896672b8bd6612
user@ubuntu:~$ docker network connect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ 
user@ubuntu:~$ 
user@ubuntu:~$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
592: eth0@if593: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 172.30.0.2/24 brd 172.30.0.255 scope global eth0
       valid_lft forever preferred_lft forever
596: eth3@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 172.20.0.2/16 brd 172.20.255.255 scope global eth3
       valid_lft forever preferred_lft forever
user@ubuntu:~$ ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
596: eth3@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP 
    inet6 2020:db8:2222::2/64 scope global nodad 
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe14:2/64 scope link 
       valid_lft forever preferred_lft forever
user@ubuntu:~$ ip -4 route
default via 172.20.0.1 dev eth3 
172.20.0.0/16 dev eth3 proto kernel scope link src 172.20.0.2 
172.30.0.0/24 dev eth0 proto kernel scope link src 172.30.0.2 
user@ubuntu:~$ ip -6 route
2020:db8:2222::/64 dev eth3 proto kernel metric 256 pref medium
3000::11 dev eth3 proto kernel metric 256 expires 2591973sec pref medium
fe80::/64 dev eth3 proto kernel metric 256 pref medium
default via 2020:db8:2222::1 dev eth3 metric 1024 pref medium
default via fe80::2d0:d6ff:fe54:5565 dev eth3 proto ra metric 1024 expires 1773sec pref medium
user@ubuntu:~$ 
user@ubuntu:~$ docker network disconnect test_vlan docker-ubuntu-0fBKobhl
user@ubuntu:~$ docker network rm test_vlan
test_vlan

Problem solved by add these two options in file daemon.json :

“ipv6”: true,
“fixed-cidr-v6”: “2001:db8:1::/64”