If your virtual machine has been moved to a different network or assigned a new IP address, you will need to update the network configuration inside the operating system.
Before making any changes, make sure you have the following information:
On Linux systems, you can check the current network configuration with:
ip addr
ip route
Identify the active network interface. Common interface names include:
eth0
ens18
ens3
enp1s0
The configuration method depends on the Linux distribution installed on your virtual machine
Check the current configuration:
cat /etc/network/interfaces
Edit the network configuration:
nano /etc/network/interfaces
Example configuration:
auto eth0
iface eth0 inet static
address 192.0.2.10/24
gateway 192.0.2.1
Replace the example IP address, CIDR, and gateway with the new network information assigned to your virtual machine
Do not change the interface name unless your server uses a different interface such as ens18, ens3, or enp1s0
Check the available Netplan configuration files:
ls /etc/netplan/
Edit the Netplan configuration file:
nano /etc/netplan/*.yaml
Example:
network:
version: 2
ethernets:
eth0:
addresses:
- 192.0.2.10/24
routes:
- to: default
via: 192.0.2.1
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
Apply the new configuration:
netplan apply
Check the available NetworkManager connections:
nmcli connection show
Configure the new IP address:
nmcli connection modify "System eth0" ipv4.addresses 192.0.2.10/24
nmcli connection modify "System eth0" ipv4.gateway 192.0.2.1
nmcli connection modify "System eth0" ipv4.method manual
Apply the configuration:
nmcli connection up "System eth0"
Replace System eth0 with the actual connection name displayed by:
nmcli connection show
Check that the new IP address has been applied:
ip addr
Check the routing table and default gateway:
ip route
Test external network connectivity:
ping -c 4 1.1.1.1
Then test DNS resolution:
ping -c 4 google.com
If you are connected to the virtual machine through SSH using the old IP address, your SSH connection may be lost immediately after applying the new network configuration.
We recommend performing network changes through the virtual machine's Console or VNC access. This allows you to regain access if the new network configuration is incorrect.