[SOLVED] How to set up Hetzner's additional IP address to point to a VM?

kartikdc

New Member
Aug 7, 2021
2
2
1
31
Hello.

I have a Proxmox host with 7 VMs. I have bought a subnet from Hetzner which came with 6 usable public IP addresses. This was easy to set up. For this, I created a Linux Bridge under Network and set the gateway to the gateway IP address that Hetzner gave. Next, I added this bridge to all the VMs. Since the VMs, were running Ubuntu, I edited the netplan configuration file to look something like this:

YAML:
network:
  ethernets:
    ...
    ens19:
      addresses:
      - <public_ip_address>/24
      gateway4: <subnet_gateway_ip_address>
      nameservers:
        addresses:
        - 8.8.8.8
        search: []
  version: 2

For the seventh VM, instead of a subnet I have received an additional IP address from Hetzner. The gateway, broadcast and netmask for this additional IP address are the same as the primary IP address for the host machine. I am not sure how to set this up.

Any tips or pointers are appreciated. Thank you.
 
Nevermind I was able to figure out how to do this.

In the host machine's /etc/network/interfaces, I added this snippet:

Code:
auto vmbr2
iface vmbr2 inet static
  address <main_ip_address>/26
  netmask <the_provided_netmask>
  bridge_ports none
  bridge_stp off
  bridge_fd 0
  up ip route add <additional_ip_address}/32 dev vmbr0

Then I added this new bridge to the VM from Proxmox's GUI and edited the netplan configuration of the VM to look like:

YAML:
network:
  ethernets:
    ...
    ens19:
      addresses:
      - <additional_ip_address>/24
      gateway4: <main_ip_address>
      nameservers:
        addresses:
        - 8.8.8.8
        search: []
  version: 2

Then in the VM, I did:

Code:
netplan generate
netplan apply

And it works.