Good thing you send me on that suicide mission as it worked out after all @tomp!
So here the in my opinion simplest and most feature rich approach, as I can limit egress and ingress of the network.
Setting up Netplan
$macaddress
, $ipv6address
, $ipv4address
and $ipv4gateway
have to be set/changed to your addresses. And eth0
my default physical interface may have a different name for you.
cat > /etc/netplan/01-netcfg.yaml <<EOF
network:
version: 2
renderer: networkd
ethernets:
eth0:
match:
macaddress: $macaddress
addresses:
- $ipv4address/32
- $ipv6address/128
routes:
- to: ::/0
via: fe80::1
routes:
- to: 0.0.0.0/0
via: $ipv4gateway
on-link: true
nameservers:
search: [ invalid ]
addresses:
- 1.1.1.1 # These four entries are Cloudflare's DNS
- 1.0.0.1
- 2606:4700:4700::1111
- 2606:4700:4700::1001
EOF
Setting up the Kernel NDP proxying and forwarding
cat >>/etc/sysctl.conf <<EOF
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.eth0.forwarding=1
net.ipv6.conf.all.proxy_ndp=1
net.ipv6.conf.eth0.proxy_ndp=1
EOF
Also make sure IPv6 is not disabled in this file.
UFW Change - If UFW is used
nano /etc/default/ufw
Make this change: DEFAULT_FORWARD_POLICY="ACCEPT"
Then do a reboot.
Install and setup LXD
When initiating LXD after the install put the IPv6/64 range as the lxdbr0 IPv6 address. If already installed you can run:
lxc network set lxdbr0 ipv6.address $ipv6address/64
This way the containers are going to get an ipv6 address from lxdbr0.
Also the following options should be set:
lxc network set lxdbr0 ipv6.dhcp false
lxc network set lxdbr0 ipv6.nat false
lxc network set lxdbr0 ipv6.routing true
The ipv4 stuff can be left alone and stay with NAT.
Run a Linux Container and enjoy
lxc launch ubuntu:18.04 c1
Enjoy a container with and universally routable IPv6.
To get the address you can run lxc list
Special Thanks
This would not have been possible without the help and tutorials of Thomas Parrott @tomp and Ryan Young @yoryan. Thank you both very very much!