Learn how to use network bridging to configure internet access for your virtual machines.
Bridged networking can be used to configure your virtual machines. Some tweaking is necessary to make the network configuration work on our network.
Requirements
- a dedicated server with a hypervisor installed (e.g. VMware ESXi, Citrix Xen Server, Proxmox, etc.)
- at least one Additional IP address attached to the server
- access to the OVHcloud Control Panel
- This feature might be unavailable or limited on servers of the Eco product line.
- This guide does not apply to servers of the ranges Scale and High Grade.
- Please visit the dedicated configuration page.
Instructions
The basic steps are always the same, independent of the underlying system:
- Creating a virtual MAC address for an Additional IP
- Setting the MAC of the VM to that new virtual MAC address
- Configuring the IP address, netmask, gateway, and route to the gateway inside the VM
Code samples in the following instructions have to be replaced with your own values:
- SERVER_IP = The main IP address of your server
- ADDITIONAL_IP = The address of your Additional IP
- GATEWAY_IP = The address of your default gateway
Step 1: Assign a virtual MAC address
Log in to the OVHcloud Control Panel, go to the Bare Metal Cloud
section, and open the IP
menu.
Click the Additional IP
tab.
Next, locate your Additional IP address in the table and click the more options ...
button. Select Add a virtual MAC
.
Choose ovh
from the Type drop-down menu unless you are using VMware ESXi - in which case choose VMware
. Type a name in the Name of virtual machine field, and click on Confirm
.
Step 2: Determine the gateway address
To configure your virtual machines for internet access, you will need to know the gateway of your host machine (i.e. your dedicated server). The gateway IP address is made up of the first three octets of your server's main IP address, with 254 as the last octet. For example, if your server's main IP address was:
- 169.254.10.20
Your gateway address would therefore be:
- 169.254.10.254
You can also retrieve the gateway via the OVHcloud Control Panel or the OVHcloud API.
Via the OVHcloud Control Panel
Log in to the OVHcloud Control Panel, go to the Bare Metal Cloud
section, and select your server in the Dedicated Servers section.
The IPv4 gateway assigned to your server will appear in the Network
section of the General Information
tab. Once you have copied it, continue with applying the configuration.
Via the OVHcloud API
On the OVHcloud API, execute the following API call, indicating the internal server name (example: ns3956771.ip-169-254-10.us
):
GET /dedicated/server/{serviceName}/specifications/network
Step 3: Prepare the host
Proxmox
After creating the VM and while it is still powered off, right-click the VM and click Edit settings
.
- Select the VM.
- Open the
Hardware
section. - Select
Network Device
. - Click the
Edit
button.
Then add the vMAC address created previously.
Now you can start the VM and proceed with the configuration steps, depending on the operating system installed.
VMware ESXi
After creating the VM and while it is still powered off, right-click the VM and click Edit settings
.
Fold out Network Adapter 1
, change the value in the MAC Address
drop-down menu to Manual
, and enter the MAC address created previously.
Now you can start the VM and proceed with the configuration steps, depending on the operating system installed.
Step 4: Configure the virtual machines
Debian
Connect to the shell of your virtual machine. Open the virtual machine's network configuration file located in /etc/network/interfaces
. Edit the file so that it reflects the configuration below (please remember to fill in your own values).
- For older distributions:
auto lo eth0 iface lo inet loopback iface eth0 inet static address ADDITIONAL_IP netmask 255.255.255.255 broadcast ADDITIONAL_IP post-up route add GATEWAY_IP dev eth0 post-up route add default gw GATEWAY_IP pre-down route del GATEWAY_IP dev eth0 pre-down route del default gw GATEWAY_IP
- For the latest distributions:
auto lo eth0 iface lo inet loopback iface eth0 inet static address ADDITIONAL_IP netmask 255.255.255.255 broadcast ADDITIONAL_IP post-up ip route add GATEWAY_IP dev eth0 post-up ip route add default via GATEWAY_IP pre-down ip route del GATEWAY_IP dev eth0 pre-down ip route del default via GATEWAY_IP
Also, replace eth0
if your system uses Predictable Network Interface Names. You can find the network interface names with the following command:
ls /sys/class/net
Save and close the file, then restart your network or reboot the virtual machine.
Red Hat and Red Hat-based operating systems (CentOS 6, Scientific Linux, ClearOS, etc.)
Open a terminal on your virtual machine. Open the virtual machine's network configuration file located in /etc/network/interfaces
. Edit the file so that it reflects the configuration below (please remember to fill in your own values).
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.255 IPADDR=ADDITIONAL_IP GATEWAY=GATEWAY_IP ARP=yes HWADDR=MY:VI:RT:UA:LM:AC
Save and close the file.
Next, open the virtual machine's routing file, which is located in /etc/sysconfig/network-scripts/route-eth0
. Edit the file so that it reflects the configuration below (please remember to fill in your own values).
GATEWAY_IP dev eth0 default via GATEWAY_IP dev eth0
Save and close the file, then reboot your virtual machine.
CentOS 7
ls /sys/class/net
.Open a terminal on your virtual machine. Open the virtual machine's network configuration file located in /etc/sysconfig/network-scripts/ifcfg-(interface-name)
. Edit the file so that it reflects the configuration below (please remember to fill in your own values).
DEVICE=(interface-name) BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.255 IPADDR=ADDITIONAL_IP GATEWAY=GATEWAY_IP ARP=yes HWADDR=MY:VI:RT:UA:LM:AC
Save and close the file.
Next, open the virtual machine's routing file, which is located in /etc/sysconfig/network-scripts/route-(interface-name)
. Edit the file so that it reflects the configuration below (please remember to fill in your own values).
GATEWAY_IP - 169.254.10.254 (interface-name) NETWORK_GW_VM - 255.255.255.0 (interface-name) default GATEWAY_IP
Save and close the file.
Next, open the virtual machine's DNS configuration file, which is located in /etc/resolv.conf
, and add this line:
nameserver 213.186.33.99
After saving and closing the file, restart your network or reboot the VM.
FreeBSD 12.0
Open a terminal on your virtual machine. Open the virtual machine's network configuration file located in /etc/rc.conf
. Edit the file so that it reflects the configuration below (please remember to fill in your own values). In this example, the interface name is em0
. Replace this value if it does not apply.
ifconfig_em0="inet ADDITIONAL_IP netmask 255.255.255.255 broadcast ADDITIONAL_IP" static_routes="net1 net2" route_net1="-net GATEWAY_IP/32 -interface em0" route_net2="default GATEWAY_IP"
Save and close the file.
Next, edit or create the file /etc/resolv.conf
and add this line.
nameserver 213.186.33.99
Save and close the file, then reboot your virtual machine.
Ubuntu 18.04
First, open a terminal on your virtual machine and open the network configuration file located in /etc/netplan/
with the following command. For demonstration purposes, our file is called 50-cloud-init.yaml
.
# nano /etc/netplan/50-cloud-init.yaml
Once the file is open for editing, amend it with the following code:
network: ethernets: (interface-name): addresses: - ADDITIONAL_IP/32 nameservers: addresses: - 213.186.33.99 search: [] optional: true routes: - to: 0.0.0.0/0 via: GATEWAY_IP on-link: true version: 2
Save and close the file, then run the following command:
netplan try Warning: Stopping systemd-networkd.service, but it can still be activated by: systemd-networkd.socket Do you want to keep these settings? Press ENTER before the timeout to accept the new configuration Changes will revert in 120 seconds Configuration accepted.
Windows Server 2012 / Hyper-V
Before configuring your virtual machine, you need to create a virtual switch.
From the command line of your dedicated server, run ipconfig /all
and note the name of the network adapter that contains the server's main IP address.
In the Hyper-V Manager, create a new virtual switch and set the connection type to External
.
Select the adapter with the server’s IP, then tick the option Allow management operating system to share this network adapter
.
Next, select the VM to which you want to add the Additional IP. Use the Hyper-V Manager to change the settings of the VM and shut it down.
Expand the network adapter in the left-hand menu and click on Advanced Features
. Change the MAC address to Static
, and enter the virtual MAC address for the Additional IP. Once you have entered these settings, press OK
to apply the changes.
Next, start the VM and log in as an administrator, then go to the Control Panel
's Network and Sharing Center
. Click on Ethernet
to open the settings and click on the Properties
button to view the Ethernet Properties
.
Select Internet Protocol Version 4 (TCP/IPv4)
, and then click on the Properties
button.
In the IPv4 Properties window, select Use the following IP address
. Enter the Additional IP into the IP address field, and enter 255.255.255.255 into the subnet mask.
Fill in your server’s gateway IP address in the appropriate field below and enter 213.186.33.99 into the Preferred DNS Server
field.
Finally, click OK
, and ignore the warning message about the gateway IP and the assigned IP not being in the same subnet.
After rebooting the server, the VM should be connected to the internet using the Additional IP.
Troubleshooting
If you are unable to establish a connection from your VM to the public network and you suspect a networking problem, please reboot the server in rescue mode and set up the bridging network interface directly on the host.
Enter the following command in the rescue mode terminal, in which you replace MAC_ADDRESS with the vMAC address that you have generated in the Control Panel and ADDITIONAL_IP with your Additional IP address:
ip link add name test-bridge link eth0 type macvlan ip link set dev test-bridge address MAC_ADDRESS ip link set test-bridge up ip addr add ADDITIONAL_IP/32 dev test-bridge
Next, ping your Additional IP address from an external device.
-
If it responds, that probably means that there is a configuration error either on the VM or the host that prevents the Additional IP from working in normal mode.
-
If the IP address is still not working, please create a ticket in your OVHcloud Control Panel to relay your test results to our support teams.
Go further
For more information and tutorials, please see our other Dedicated Server support guides or explore the guides for other OVHcloud products and services.