Scaleway DocumentationDedibox NetworkFailover IPHow to
Configure the network of a virtual machine

Jump toUpdate content

How to configure the network of a virtual machine

Reviewed on 29 July 2021Published on 29 July 2021
Requirements:

When you install your server with a virtualization solution like VMware vSphere Hypervisor (ESXi) or Proxmox you can create multiple virtual machines on the physical server.

This can be used to have separate environments to divide between your different services (for example keeping mail and web services on different VMs) or to launch several virtual machines to make better use of the performance of the server.

To communicate on the Internet each of your virtual machines needs an IP address. You can use failover IP’s to have additional IP addresses available for your server.

Tip:

You can configure a unique gateway for your virtual machines. In doing so, your VMs can move between your hypervisors without changing the network configuration of the virtual machine.

  • IP address of the unique gateway: 62.210.0.1

You can find below, examples for the configuration of the network interfaces on different distributions inside a virtual machine:

Ubuntu

Since the release of version 18.04 (Bionic Beaver) Ubuntu has switched to Netplan for the configuration of network interfaces. For older releases of the distribution, refer to the configuration for Debian.

  1. Log into your virtual machine and open the network configuration file /etc/netplan/01-netcfg.yml in a text editor of your choice, for example nano:

    sudo nano /etc/netplan/01-netcfg.yml 
  2. Create a network configuation as follows. Remember to replace fail.over.ip.address with your failover IP address:

    network:    version: 2    renderer: networkd    ethernets:        eth0:        dhcp4: no        dhcp6: no        addresses: [fail.over.ip.address/32]        gateway4: 62.210.0.1        nameservers:            addresses: [62.210.16.6, 62.210.16.7]        routes:        - to: 62.210.0.1/32            via: fail.over.ip.address            scope: link
  3. Save the file and exit the text editor.

  4. Apply the new configuration:

    sudo netplan apply

Debian

  1. Log into the virtual machine and edit the file /etc/network/interfaces/ with a text editor of your choice, for example, nano:

    nano /etc/network/interfaces
  2. Configure the network interface as follows. Remember to replace fail.over.ip.address with your failover IP address:

    auto eth0    iface eth0 inet static    address fail.over.ip.address    netmask 255.255.255.255    pointopoint 62.210.0.1    gateway 62.210.0.1
  3. Save the file and exit the text editor.

  4. Set the DNS server information by editing the file /etc/resolv.conf:

    nano /etc/resolv.conf
  5. Set the DNS resolver by adding the following lines to the file. Then save it and exit the text editor:

    nameserver 62.210.16.6nameserver 62.210.16.7
    Note:

    The DNS resolvers above are operated by Scaleway. You can also set your preferred alternative DNS resolvers in the file.

  6. Activate the network on your virtual machine by running the following code:

    ifup eth0

CentOS

  1. Log into the virtual machine and edit the file /etc/sysconfig/network-scripts/ifcfg-eth0 with a text editor of your choice, for example, nano:
```sh nano /etc/sysconfig/network-scripts/ifcfg-eth0```
  1. Configure the network interface as follows. Remember to replace fail.over.ip.address with your failover IP address and virtual:mac:address with the virtual MAC of the VM:

    DEVICE=eth0BOOTPROTO=noneONBOOT=yesUSERCTL=noIPV6INIT=noPEERDNS=yesTYPE=EthernetNETMASK=255.255.255.255IPADDR=fail.over.ip.addressGATEWAY=62.210.0.1DNS1=62.210.16.6DNS2=62.210.16.7ARP=yesHWADDR=virtual:mac:address
  2. Save the file and close the text editor.

  3. Edit the file /etc/sysconfig/network-scripts/route-eth0 as follows, then save and exit the text editor:

    62.210.0.1 dev eth0default via 62.210.0.1 dev eth0
  4. Run the following command to bring the network interface up:

    ifup eth0

Windows Server

  1. Connect to the desktop of your VM in the virtual console, then open the network settings of your server.

  2. Enter the following information in the network adapter configuration:

    * Address: Failover IP* Subnetmask: `255.255.255.255`* Gateway: `62.210.0.1`* DNS 1: `62.210.16.6`* DNS 2: `62.210.16.7`
    See Also