Consider I have a vagrant machine with a public network.
ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::af55:3360:45cc:13ea prefixlen 64 scopeid 0x20<link>
ether 08:00:27:37:f8:46 txqueuelen 1000 (Ethernet)
RX packets 12596 bytes 4067678 (3.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7706 bytes 4041830 (3.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.100.1.27 netmask 255.255.255.0 broadcast 192.100.1.255
inet6 fe80::a00:27ff:fe40:a0d0 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:40:a0:d0 txqueuelen 1000 (Ethernet)
RX packets 20 bytes 6840 (6.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19 bytes 2550 (2.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I want to add an ipv6 ip to the public network interface. Is this possible in vagrant?
Final expected config:
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 192.100.1.27 netmask 255.255.255.0 broadcast 192.100.1.255
inet6 fe80::6f09:6698:1cc8:acab prefixlen 64 scopeid 0x20<link>
inet6 2a00:81c0:6001:141::a prefixlen 64 scopeid 0x0<global>
ether fa:16:3e:19:aa:f4 txqueuelen 1000 (Ethernet)
RX packets 1053729 bytes 358588297 (341.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 272053 bytes 62702710 (59.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I couldn't find a configuration I can set to achieve this. So I created a script that runs during vagrant provisioning that uses nmcli
to add the ip to the interface. I am not sure if this is the best way to this, but it works.
echo "Setting network config for this node"
nmcli con add type ethernet ifname enp0s8 con-name public
nmcli con modify public ipv4.method manual +ipv4.addresses 192.100.1.27
nmcli con modify public connection.autoconnect "yes"
nmcli con modify public +802-3-ethernet.mtu 1450
nmcli con modify public ipv6.method manual +ipv6.addresses 2a00:81c0:6001:141::a/64
nmcli con up public
I had to add this to the Vagrantfile.
c.vm.provision :shell, path: "path_to_script"