Attach (private) IPv4 address to a running VM
Issue: IPv4 addresses are not pingable / usable out of the box after they are attached to a running VM. The netplan config needs to be changed aswell. The same applies to private IPv4 addresses.
Solution:
Login to the VM where you want to add the (private) IPv4 address
Navigate to the netplan config under “/etc/netplan”
As root, open the “50-cloud-init.yaml” file with your preferred text editor
Replace the existing configuration with the following:
network:
ethernets:
enp1s0:
addresses:
- < VM public IPv6 address eg. 2a11:cc81:0:2a::1/64 >
- < VM public IPv4 address eg. 176.56.139.33/32 >
- < VM private IPv4 address eg. 192.168.1.1/24 >
dhcp4: false
dhcp6: false
nameservers:
addresses:
- 2001:4860:4860::8888
- 2001:4860:4860::8844
routes:
- on-link: true
to: 0.0.0.0/0
via: 169.254.1.1
- on-link: true
to: ::/0
via: fe80::1
version: 2
Save the configuration
Apply the netplan configuration with “sudo netplan apply”
Opt. repeat the upper steps for other VM’s in the same network
Test connection with ping
Note:
Private IPs should be in the same network/subnet
Private IPs created in Boden VM and Lefdal VM, even when in the same subnet, won’t be reachable among each other
Public IPv4 and IPv6 are reachable from everywhere