On Fedora when we create a Virtual Machine (via libvirt) we get an IPv4 address (NAT). But for my experiment I wanted a NATed IPv6 address. With the following steps one can get NATed IPV6 address on VMs.
On the host
First, stop the default network and edit the configuration
# virsh net-destroy default # virsh net-edit default
Add the following for IPv6.
<ip family='ipv6' address='fd01:db8:dead:beef:fe::2' prefix='96'> <dhcp> <range start='fd01:db8:dead:beef:fe::1000' end='fd01:db8:dead:beef:fe::2000' /> </dhcp> </ip>
Now restart the network.
# virsh net-start default
Configuring the VM (Debian 11)
Debian VM never got the IPv6 address from DHCP. Followed these steps to get one:
/etc/network/interfaces to add the following line
iface enp1s0 inet6 dhcp at the end. Now the file looks following :
# The primary network interface allow-hotplug enp1s0 iface enp1s0 inet dhcp iface enp1s0 inet6 dhcp
iface enp1s0 inet6 dhcp in the
we are actually telling network interface to get an IPv6 address from DHCP.
Reboot the system and check the IP address.