Bridge with a static IP with netplan

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

Bridge with a static IPv4 and IPv6 with netplan, with Hetzner.

By default, a bridge will change interface's MAC address, some hostings (i.e. Hetzner) are not happy with it.

Add the following to your startup scripts (i.e. /etc/rc.local) to make sure bridge's MAC address stays the same.

# Make sure the bridge uses proper MAC
ifconfig vmbr0 hw ether $(cat /sys/class/net/eno1/address)


/etc/netplan/01-netcfg.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
  bridges:
    vmbr0:
      interfaces: [eno1]
      dhcp4: no
      dhcp6: no
      addresses:
        - 176.9.137.231/32
        - 2a01:4f8:160:11eb::2/64
      routes:
        - on-link: true
          to: 0.0.0.0/0
          via: 176.9.137.225
      gateway6: fe80::1
      nameservers:
        addresses:
          - 213.133.98.98
          - 213.133.100.100
          - 213.133.99.99
          - 2a01:4f8:0:1::add:1010
          - 2a01:4f8:0:1::add:9999
          - 2a01:4f8:0:1::add:9898