I have a load of VMs on various cloud service providers such as AWS and Digital Ocean. It’s gotten to the point now where I figured I could save money, have a fixed cost, gain some experience, and get much better performance if I was to just rent a dedicated Debian 10 server from Hetzner, pay for an additional subnet, and set up the VMs as guests under KVM (like I’ve done at home).
Unfortunately, I just can’t seem to figure out how to configure the /etc/network/interfaces
file for acting as a bridge for my guests.
At home, this was really simple, and I just had the following example configuration:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp35s0
iface enp35s0 inet manual
auto kvmbr0
iface kvmbr0 inet static
address 192.168.1.19
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
bridge_ports enp35s0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
Unfortunately, it is not so simple with hetzner. For a start, I have a single static IP and a separate subnet that I bought for my VMs. There was no option to just have a single subnet with lots of IPs when I ordered the server, which would have been simpler/nicer.
The primary IP details for my server are:
- address
95.217.122.234
- netmask
255.255.255.192
- gateway
95.217.122.193
The additional subnet I received is: 95.216.106.56 / 29
- Network
95.216.106.56
- Gateway:
95.217.122.234
- Netmask:
255.255.255.248
- broadcast:
95.216.106.63
I originally tried the following network configuration, which failed. (Failed meaning that I could no longer SSH into the server. I would apply a network configuration by performing sudo service networking restart
, or just rebooting the server when I am connected via the KVM spider.)
### Hetzner Online GmbH installimage
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto enp35s0
iface enp35s0 inet static
address 95.217.122.234
netmask 255.255.255.192
gateway 95.217.122.193
# route 95.217.122.192/26 via 95.217.122.193
up route add -net 95.217.122.192 netmask 255.255.255.192 gw 95.217.122.193 dev enp35s0
iface enp35s0 inet6 static
address 2a01:4f9:4a:37d5::2
netmask 64
gateway fe80::1
# Add secondary subnet for VMs.
auto enp35s0:0
iface enp35s0:0 inet manual
# Add kvm bridge
auto kvmbr0
iface kvmbr0 inet static
address 95.216.106.56
netmask 255.255.255.248
network 95.216.106.56
broadcast 95.216.106.63
gateway 95.216.106.56
bridge_ports enp35s0:0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
Hetzner Documentation
Since then, I found this Hetzner documentation, for what looks like it is specifically talking about this problem.
I believe I should be able to use direct routing and would prefer that over a “brouter”, but I think if I did this, I need to recieve MAC addresses from hetzner, and I believe this is only possible when you buy individual IPs and not subnets, so I may need to swap my subnet out with a bunch of individual IPs?
I tried both methods with the following configurations, all of which failed for me. Perhaps someone can point out where I’m messing up?
Brouter FAILED
auto enp35s0
iface enp35s0 inet static
address 95.217.122.234
netmask 255.255.255.255
pointopoint 95.217.122.193
gateway 95.217.122.193
iface enp35s0 inet6 static
address 2a01:4f9:4a:37d5::2
netmask 64
gateway fe80::1
auto kvmbr0
iface kvmbr0 inet static
address 95.217.122.234
netmask 255.255.255.255
bridge_ports none
bridge_stp off
bridge_fd 0
pre-up brctl addbr virbr1
up ip route add 95.216.106.56/29 dev virbr1
down ip route del 95.216.106.56/29 dev virbr1
iface kvmbr0 inet6 static
address 2a01:4f9:4a:37d5::2
netmask 64
Direct Routing Bridge 1 (FAILED)
### Hetzner Online GmbH installimage
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface lo inet6 loopback
# deliberately no configuration for enp35s0 here
auto kvmbr0
iface kvmbr0 inet static
address 95.217.122.234
netmask 255.255.255.192
gateway 95.217.122.193
bridge_ports enp35s0
bridge_stp off
bridge_fd 1
bridge_hello 2
bridge_maxage 12
Direct Routing Bridge 2 (Failed)
### Hetzner Online GmbH installimage
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface lo inet6 loopback
allow-hotplug enp35s0
iface enp35s0 inet manual
auto kvmbr0
iface kvmbr0 inet static
address 95.217.122.234
netmask 255.255.255.192
gateway 95.217.122.193
bridge_ports enp35s0
bridge_stp off
bridge_fd 1
bridge_hello 2
bridge_maxage 12
# route 95.217.122.192/26 via 95.217.122.193
up route add -net 95.217.122.192 netmask 255.255.255.192 gw 95.217.122.193 dev enp35s0
Original (Working) Configuration
For references, below is the working configuration that came with my server and which I restore through a KVM console, every time I lose access to the server.
### Hetzner Online GmbH installimage
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto enp35s0
iface enp35s0 inet static
address 95.217.122.234
netmask 255.255.255.192
gateway 95.217.122.193
# route 95.217.122.192/26 via 95.217.122.193
up route add -net 95.217.122.192 netmask 255.255.255.192 gw 95.217.122.193 dev enp35s0
iface enp35s0 inet6 static
address 2a01:4f9:4a:37d5::2
netmask 64
gateway fe80::1
Side Problem - KVM Keyboard Input Pain
As a side note, using the “Lantronix SLSLP KVM Console” is a real pain in the butt due to various issues with the keyboard input that I can’t seem to resolve. If you have any advice on this it is much appreciated.
- Tab completion doesn’t work, instead it seems to move focus so that typing anything further doesn’t work and you need to click on the window again.
-
y
is mapped toz
and vice-versa. -
- is mapped to a funky B shpaed character, can get around this by using - on the number pad instead.
-
/
is mapped to-
, can get around this by useing the number pad.
I have tried using sudo dpkg-reconfigure keyboard-configuration
to change the keyboard input, trying both a Generic 105-key PC (intl.) and leaving it on the Generic 104-key PC because that is what the console appears to be using.
After setting the number of keys, I had set the Keyboard layout is set to English (UK), yet the mappings are still wrong.
Any and all help is much appreciated!