Configuring IPv6 on virtual machines with ESXi
- compute
- dedibox
- esxi
- vm
- virtual-machine
- ubuntu
This tutorial explains how to configure IPv6 on virtual machines on ESXi hypervisors.
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have configured your SSH Key
- You have a Dedibox running ESXi 6.5 or later
- You have enabled SLAAC for your Dedibox
- You have requested an IPv6 prefix
- You have installed a virtual machine running Ubuntu 20.04 or later and configured a failover IPv4 on it
-
Log into your virtual machine using SSH.
-
Run the command
ip a
to display your current network configuration. The command returns an output as follows:1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:50:56:01:fa:b9 brd ff:ff:ff:ff:ff:ffaltname enp3s0inet your.fail.over.ip/32 scope global ens160valid_lft forever preferred_lft foreverinet6 fe80::250:56ff:fe01:fab9/64 scope linkvalid_lft forever preferred_lft foreverTake note of the following information from the output above:
- The name of the network interface (here
ens160
) - The local IPv6 of your VM (here
fe80::250:56ff:fe01:fab9/64
)
- The name of the network interface (here
-
Open the file
/etc/dhcp/dhclient6.conf
in a text editor and edit it as shown below. Then save the file and quit the text editor.interface "ens160" {send dhcp6.client-id DUID;}Important:Edit the name of the Internet interface to the one of your VM and replace
DUID
with the DUID of your prefix. -
Open the file
/etc/systemd/system/dhclient.service
in a text editor and edit it as shown below. Then save and exit the editor.[Unit]Description=dhclient for sending DUID IPv6After=network-online.targetWants=network-online.target[Service]Restart=alwaysRestartSec=10Type=forkingExecStart=/sbin/dhclient -cf /etc/dhcp/dhclient6.conf -6 -P -v eno1ExecStop=/sbin/dhclient -x -pf /var/run/dhclient6.pid[Install]WantedBy=network.target -
Enable the service to start automatically after each reboot of the machine. Then start the service manually for the first time.
systemctl enable dhclient.servicesystemctl start dhclient.service -
Verify that the service is running with the following command:
systemctl status dhclient.serviceThe command above returns an output as follows:
● dhclient.service - dhclient for sending DUID IPv6Loaded: loaded (/etc/systemd/system/dhclient.service; enabled; vendor pres>Active: active (running) since Thu 2022-02-24 12:18:03 UTC; 27min agoMain PID: 5342 (dhclient)Tasks: 4 (limit: 4627)Memory: 1.6MCPU: 23msCGroup: /system.slice/dhclient.service└─5342 /sbin/dhclient -cf /etc/dhcp/dhclient6.conf -6 -P -v ens160 -
Edit your Netplan configuration file (probably located at
/etc/netplan/01-netcfg.yaml
) and edit it as follows:network:version: 2renderer: networkdethernets:ens160:dhcp4: falsedhcp6: falseaddresses:- FAILOVER_IP/32- IP_FROM_YOUR_PREFIX/SUBNETgateway4: 62.210.0.1gateway6: LOCAL_IPv6nameservers:addresses: [62.210.16.6, 62.210.16.7]routes:- to: 0.0.0.0/0via: 62.210.0.1on-link: true- to: "::/0"via: "LOCAL_IPv6"on-link: true -
Apply the new network configuration with the following command:
netplan applyYou now have configured the IP address, but the IPv6 connectivity is not working yet.
-
Find the gateway for your prefix by running the following command:
ip -6 routeThe command returns an output as follows:
::1 dev lo proto kernel metric 256 pref mediumYOUR_IPv6_PREFIX/SUBNETMASK dev ens160 proto kernel metric 256 pref mediumfe80::/64 dev ens160 proto kernel metric 256 pref mediumdefault via fe80::7a0c:f0ff:fedf:254d dev ens160 proto static metric 1024 onlink pref mediumTake a note of the default gateway (here
fe80::7a0c:f0ff:fedf:254d
). -
Edit your Netplan configuration file again and modify it as follows:
gateway6: DEFAULT_GATEWAY- to: "::/0"via: "DEFAULT_GATEWAY"on-link: trueNote:Remember to replace
DEFAULT_GATEWAY
with the default gateway found in the previous step. -
Reload your network configuration for the last time:
netplan apply
You have now IPv6 connectivity for your virtual machine. You can test it by running a ping6: ping ipv6.google.com
.