Hi, How can i use IPv6 static address with stateful dhcp?
I saw Github issue #3519 and topic ‘Using static IPs with LXD’ .
They said we need to set the ipv6.dhcp.stateful
property on the network to true
to have LXD run dnsmasq in stateful mode.
I tried it as below, but it didn’t work well.
ubuntu@ubuntu18:~$ lxc network create lxd0719 ipv6.dhcp.stateful=true
Network lxd0719 created
ubuntu@ubuntu18:~$ lxc init images:ubuntu/xenial test0719
Creating test0719
ubuntu@ubuntu18:~$ lxc config device add test0719 eth0 nic nictype=bridged parent=lxd0719 ipv4.address=10.228.181.123 ipv6.address=fd42:7e3e:264b:5dca::123
Device eth0 added to test0719
ubuntu@ubuntu18:~$ lxc start test0719
ubuntu@ubuntu18:~$ lxc exec test0719 bash
root@test0719:~# vim /etc/network/interfaces
root@test0719:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp
root@test0719:~# reboot
ubuntu@ubuntu18:~$ lxc list test0719
+----------+---------+-----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+-----------------------+------+------------+-----------+
| test0719 | RUNNING | 10.228.181.129 (eth0) | | PERSISTENT | 0 |
+----------+---------+-----------------------+------+------------+-----------+
ubuntu@ubuntu18:~$ lxc config show test0719
architecture: x86_64
config:
image.architecture: amd64
image.description: Ubuntu xenial amd64 (20180718_07:42)
image.os: Ubuntu
image.release: xenial
image.serial: "20180718_07:42"
volatile.base_image: bf0b1111f90a161a5e905c76a3021cb09e3668dc8c7d371535cd9492a0d8dd50
volatile.eth0.hwaddr: 00:16:3e:33:1c:cd
volatile.eth0.name: eth0
volatile.idmap.base: "0"
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
volatile.last_state.power: RUNNING
devices:
eth0:
ipv4.address: 10.228.181.123
ipv6.address: fd42:7e3e:264b:5dca::123
nictype: bridged
parent: lxd0719
type: nic
ephemeral: false
profiles:
- default
stateful: false
description: ""
ubuntu@ubuntu18:~$ lxc network show lxd0719
config:
ipv4.address: 10.228.181.1/24
ipv4.nat: "true"
ipv6.address: fd42:7e3e:264b:5dca::1/64
ipv6.dhcp.stateful: "true"
ipv6.nat: "true"
description: ""
name: lxd0719
type: bridge
used_by:
- /1.0/containers/test0719
managed: true
status: Created
locations:
- none
IPv4 and IPv6 didn’t works well, so i did as below and only IPv4 work well. Ipv6 didn’t.
ubuntu@ubuntu18:~$ lxc network set lxd0719 ipv4.dhcp true
ubuntu@ubuntu18:~$ lxc network set lxd0719 ipv6.dhcp true
ubuntu@ubuntu18:~$ lxc restart test0719
ubuntu@ubuntu18:~$ lxc list test0719
+----------+---------+-----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+-----------------------+------+------------+-----------+
| test0719 | RUNNING | 10.228.181.123 (eth0) | | PERSISTENT | 0 |
+----------+---------+-----------------------+------+------------+-----------+
ubuntu@ubuntu18:~$ lxc network show lxd0719
config:
ipv4.address: 10.228.181.1/24
ipv4.dhcp: "true"
ipv4.nat: "true"
ipv6.address: fd42:7e3e:264b:5dca::1/64
ipv6.dhcp: "true"
ipv6.dhcp.stateful: "true"
ipv6.nat: "true"
description: ""
name: lxd0719
type: bridge
used_by:
- /1.0/containers/test0719
managed: true
status: Created
locations:
- none
My LXD and kernel version are below.
ubuntu@ubuntu18:~$ uname -a
Linux ubuntu18 4.15.0-23-generic #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ubuntu18:~$ dpkg -l lxd*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================================-===========================-===========================-================================================================================================
ii lxd 3.0.1-0ubuntu1~18.04.1 amd64 Container hypervisor based on LXC - daemon
ii lxd-client 3.0.1-0ubuntu1~18.04.1 amd64 Container hypervisor based on LXC - client
un lxd-tools <none> <none> (no description available)