Networking for guest VM’s on OVH Hosting
If you rent a dedicated server from OVH hosting, you might want to put some sort of hypervisor on it. In my case, I’m running Proxmox 9, with multiple Ubuntu servers.
The host comes with a ‘main’ IPv4 address, and you can rent the use of a separate CIDR block as well. Both need different gateways. This will not, out of the box, work on a new guest.
Fixing Networking on VM Guests on OVH
OVH’s Networking
By hunting through OVH’s website and emails, you can determine:
- Host IP
A.A.A.A - Host IP’s Gateway
B.B.B.B - Extra range
C.C.C.C/30in my case, meaning a block of 4 IP addresses - Gateway for extra IP’s:
D.D.D.D - Virtual MAC address
EE:EE:EE:EE:EE:EE
You can get this last by going to the OVH networking page, picking an IP
address from the range like C.C.C.X, and requesting that they ‘Add a virtual MAC’.
Note that the gateway D.D.D.D ≠ B.B.B.B. Also note that D.D.D.D is not inside the CIDR block C.C.C.C/30. We will
treat all four IP addresses in C.C.C.C/30 as usable. None is a gateway, a broadcast IP or a network address.
What To Do on the Host
What is going on on the Proxmox host is this:
- Physical NIC:
enp10XXXX- connected directly to OVH’s network, enslaved to the main bridgevmbr0 - Bridge
vmbr0- acts as a Layer-2 switch between the physical NIC and any VMs’ tap interfaces (tap100i0,tap101i0) - The bridge holds the host’s own main IP
A.A.A.A/32with gatewayB.B.B.B - Each VM gets a tap device on
vmbr0 - Inside each VM, the interface (e.g. ens18) is configured with its own
/32IP (fromC.C.C.C/30) and the gatewayD.D.D.Dmarked on-link
You can make a minimal bridge on the Proxmox server by doing something like this:
auto vmbr0
iface vmbr0 inet static
address A.A.A.A/32
gateway B.B.B.B
bridge-ports enp10XXXX
bridge-stp off
bridge-fd 0
What To Do on a Guest
Guests are tricky, because they come without networking working out-of-the-box, which means there is a certain amount of manual setup to be done before you can install NetworkManger or download anything.
First of all, don’t forget to set up your guest in the Proxmox web interface using the correct MAC address. If you don’t have one, go to OVH networking page and create one. Do this while the guest is shut down or while it is being created.
Iniitial Network Setup
Within the guest, assuming you have an interface like ens18:
sudo ip addr flush dev ens18
sudo ip link set ens18 up
sudo ip addr add C.C.C.X/32 dev ens18
sudo ip route add D.D.D.D/32 dev ens18
sudo ip route replace default via D.D.D.D dev ens18 onlink
Put appropriate IP addresses here.
Try pinging something to confirm this worked:
ping 1.1.1.1
DNS Setup
Assuming networking is up, sort the DNS next. Delete the symlink at /etc/resolv.conf, replace it with a copy of
whatever it was symlinked to, and edit the stupid Ubuntu DNS thing. Where it says 127.0.0.53, change this to 8.8.8.8
or some public DNS server. You can have multiple copies of this line with other nameservers if you want.
(This all gets ripped out later in my setup, and replaced with DNS over TLS for extra security. The important thing is
to get any DNS working first, as you will then be able to do apt update and apt install commands, allowing you to
set up a more convenient environment to work in.)
Netplan
From here, sort out SSH keys so you don’t have to use the web interface, SSH in, and fix the netplan file to make your
changes to the networking persistent. It must be the highest number ’e.g. /etc/netplan/99-choose-this-one.yaml. You
cannot shorten the file extension.
network:
version: 2
renderer: NetworkManager
ethernets:
ens18:
dhcp4: no
addresses:
- "C.C.C.X/32"
routes:
- to: D.D.D.D/32
scope: link
- to: 0.0.0.0/0
via: D.D.D.D
on-link: true
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
Don’t forget to install NetworkManager:
sudo apt install network-manager
Final Step
From here, you should be able to do sudo netplan generate and sudo netplan apply, and have working networking.