How to configure the network of a virtual machine on a Dedibox host
When you install your server with a virtualization solution like Proxmox, you can create multiple virtual machines on the physical server. This setup allows you to have separate environments for different services (e.g., mail and web services) or to optimize the server's performance by running several virtual machines.
To communicate on the internet, each of your virtual machines needs an IP address. You can use failover IPs to have additional IP addresses available for your server.
Before you start
To complete the actions presented below, you must have:
- A Dedibox account logged into the console
- Created a Dedibox dedicated server and installed a hypervisor on it
- Ordered a failover IP
- Generated a virtual MAC address
Find below examples of network interface configurations on different distributions inside a virtual machine:
Ubuntu
Since the release of version 18.04 (Bionic Beaver), Ubuntu has used Netplan for configuring network interfaces. For older releases, refer to the Debian configuration.
- Log into your virtual machine and open the network configuration file
/etc/netplan/01-netcfg.yaml
in a text editor of your choice:sudo nano /etc/netplan/01-netcfg.yaml
- Create a network configuration as follows. Replace
<failover_IP>
with your failover IP address:network: version: 2 ethernets: ens18: addresses: - <failover_IP>/32 nameservers: addresses: [ "51.159.47.28", "51.159.47.26" ] routes: - to: default via: 62.210.0.1 - to: 62.210.0.1/32 via: <failover_IP> scope: link
- Save the file and exit the text editor.
- Apply the new configuration:
sudo netplan apply
Debian
- Log into the virtual machine and edit the network configuration file:
sudo nano /etc/network/interfaces
- Configure the network interface as follows. Replace
<failover_IP>
with your failover IP address:auto eth0 iface eth0 inet static address <failover_IP> netmask 255.255.255.255 pointopoint 62.210.0.1 gateway 62.210.0.1
- Save the file and exit the text editor.
- Set the DNS server information:
sudo nano /etc/resolv.conf
- Add the following DNS resolvers:
nameserver 51.159.47.28 nameserver 51.159.47.26
- Activate the network on your virtual machine:
Alternatively, you can restart networking with:
sudo ifup eth0
sudo systemctl restart networking
CentOS
- Log into the virtual machine and edit the network configuration file:
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
- Configure the network interface as follows. Replace
<failover_IP>
with your failover IP address and<virtual_MAC>
with the virtual MAC of the VM:DEVICE=eth0 BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.255 IPADDR=<failover_IP> GATEWAY=62.210.0.1 DNS1=51.159.47.28 DNS2=51.159.47.26 ARP=yes HWADDR=<virtual_MAC>
- Save and close the text editor.
- Create or edit the routing configuration file:
Add the following lines:
sudo nano /etc/sysconfig/network-scripts/route-eth0
62.210.0.1 dev eth0 default via 62.210.0.1 dev eth0
- Activate the network interface:
sudo ifup eth0
Windows Server
- Open the network settings on your VM by navigating to:
Control Panel → Network & Internet → Change Adapter Options
- Select your network adapter and enter the following details:
- IP Address:
<failover_IP>
- Subnet Mask:
255.255.255.255
- Gateway:
62.210.0.1
- DNS 1:
51.159.47.28
- DNS 2:
51.159.47.26
- IP Address: