Skip to content

Network Configuration

Hetzner

IPv4

Single IPv4 Address with RFC1918 Network for VM's and optional Portforwarding.

Enable IPv4 Forwarding.

Uncomment the Line net.ipv4.ip_forward=1 in the file /etc/sysctl.d/99-sysctl.conf

Interfaces Config

Example:

  • PublicIP: 1.2.3.4/24
  • Gateway: 1.2.3.1
  • Local Network: 10.0.0.0/24
auto enp3s0
iface enp3s0 inet static
        address 1.2.3.4/24
        gateway 1.2.3.1
        #Portforwarding to VM
        post-up iptables -t nat -A PREROUTING -i enp3s0 -p tcp --dport 8007 -j DNAT --to 10.0.0.4:8007

auto vmbr0
iface vmbr0 inet static
        address 10.0.0.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

        post-up   iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o enp3s0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o enp3s0 -j MASQUERADE
        post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
        post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1

IPv6

IPv6 /64 Network

Enable IPv6 Forwarding.

Uncomment the Line net.ipv6.conf.all.forwarding=1 in the file /etc/sysctl.d/99-sysctl.conf

Interfaces Config

Example:

  • IPv6 Network: abcd:ef::/64
  • Gateway: fe80::1
iface enp3s0 inet6 static
        address abcd:ef::1/128
        gateway fe80::1
        up sysctl -p

iface vmbr0 inet6 static
        address abcd:ef::2/64
        up ip -6 r add abcd:ef::/64 dev vmbr0