Network Configuration on Ubuntu VM - ji-it/CloudTides GitHub Wiki
Network Configuration on Ubuntu VM
When directly cloning a VM, the created VM will share the same IPv4 address with the base VM, which will cause network conflicts. Also, when running the script clone_vm.py, if the user does not specify a Guest Customization Specification, the same ip problem will happen. Therefore, it is necessary for us to learn how to configure the network on VMs.
Log in the target VM, then
$ ifconfig
to see the network configuration on the VM. Typically the first is the network adapter name.
To assign a new static ip address to the VM, edit the file /etc/network/interfaces
$ sudo nano /etc/network/interfaces
Add the following lines, the ip address can be customized, while other lines follow the settings of our vCenter server.
auto ens160
iface ens160 inet static
address 10.11.16.150
netmask 255.255.254.0
gateway 10.11.10.1
dns-nameserver 10.11.10.1
Restart the network service,
$ sudo /etc/init.d/networking restart
Type in ifconfig
to see the new network settings. It may happen there are two IPv4 addresses, use
$ ip addr
to find all the IPv4 and IPv6 addresses. If a secondary IPv4 address exists, usually the original ip same as that of the base VM, like 10.11.16.108
in our case. Delete it by
$ sudo ip addr del address dev ens160
Now all the configurations are done, the VM has a unique IPv4 address.