By default, cloud servers obtain their Primary IPv4 address via DHCP.
Their Primary IPv6 address is statically configured via a configuration generated by cloud-init.
Currently, the IPv6 configuration is queried from the metadata server on the first boot of the server.
Disable cloud-init network changes
If you want to configure your IP address(es) entirely statically, you need to disable cloud-init from modifying or regenerating the network configuration.
Add file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg:
network:
config: disabledLinux
Debian (ifup)
Edit /etc/network/interfaces, so that the resulting file looks like this:
auto eth0
iface eth0 inet static
address <your IPv4 address>
netmask 255.255.255.255
gateway 172.31.1.1
pointopoint 172.31.1.1
dns-nameservers 185.12.64.1 185.12.64.2
iface eth0 inet6 static
address <one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>
netmask 64
gateway fe80::1Execute the following command
rm /etc/network/interfaces.d/50-cloud-init.cfgAfter that, reboot the system to make sure no DHCP client is running anymore and the configuration is applied.
Ubuntu (netplan)
Edit /etc/netplan/50-cloud-init.yaml, so that the file looks like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- <your IPv4 address>/32
- <one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64
routes:
- to: 0.0.0.0/0
via: 172.31.1.1
on-link: true
- to: default
via: fe80::1
match:
macaddress: YOUR:MAC:ADDRESS
set-name: eth0After that, execute the following commands and the configuration should be applied:
sudo netplan generate
sudo netplan tryCentOS / Fedora
Edit /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection, so that the file looks like this:
[connection]
id=cloud-init eth0
uuid=<keep the UUID as is!!>
type=ethernet
[ethernet]
mac-address=<keep the HWADDR as is!!>
[ipv4]
address1=<your IPv4 address>/32,172.31.1.1
dns=185.12.64.1;185.12.64.2;
may-fail=false
method=manual
[ipv6]
address1=<one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64,fe80::1
dns=2a01:4ff:ff00::add:1;2a01:4ff:ff00::add:2;
may-fail=false
method=manual
[proxy]
[user]
org.freedesktop.NetworkManager.origin=cloud-initAfter that, execute the following commands and the configuration should be applied:
nmcli connection down "cloud-init eth0" ; nmcli connection up "cloud-init eth0"Other operarting systems
FreeBSD
Edit /etc/rc.conf and add/changed the following parameters:
ifconfig_vtnet0="<your IPv4 address>/32"
static_routes="gateway default"
route_gateway="-host 172.31.1.1 -interface em0"
route_default="default 172.31.1.1"
ifconfig_vtnet0_ipv6="inet6 <one IPv6 address from your subnet, e.g. 2a01:4f8:0::1>/64"
ipv6_defaultrouter="fe80::1%vtnet0"