Skip to content

Instantly share code, notes, and snippets.

@strarsis
Last active February 13, 2023 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strarsis/970f77b766921841b7ae453c74e970b1 to your computer and use it in GitHub Desktop.
Save strarsis/970f77b766921841b7ae453c74e970b1 to your computer and use it in GitHub Desktop.
Hetzner Cloud netplan configuration for IPv4+IPv6 (Dual Stack)
# /etc/netplan/50-cloud-init.yml
# Ensure that other netplan config yml files in /etc/netplan/ don't interfere with this configuration
network:
version: 2
renderer: networkd
ethernets:
ens3: # (Primary interface, usually ens3 or ens33 on recent Ubuntus)
addresses:
- <Hetzner instance IP4>/32
- <Hetzner instance IP6>::1/64
routes:
- to: 0.0.0.0/0
via: 172.31.1.1
on-link: true
gateway6: fe80::1
accept-ra: true # needs to be enabled!
nameservers:
addresses: # (Hetzner DNS servers)
- 213.133.98.98
- 213.133.99.99
- 213.133.100.100
- 2a01:4f8:0:1::add:1010
- 2a01:4f8:0:1::add:9999
- 2a01:4f8:0:1::add:9898
@frennkie
Copy link

Error in network definition: expected mapping (check indentation)

Got an error.. nameservers: needs an additional line for addresses:

@strarsis
Copy link
Author

@frennkie: You are right, the field was missing. I added it.

@No0key
Copy link

No0key commented Oct 5, 2021

@strarsis hello! i'm trying completely disable ipv6 on Ubuntu 20.04 for my cloud instance,and I wrote in the sysctl.conf file such parameters
net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6 = 1
Then I reboot my instance and ipv6 still enabled, only works if I use sysctl -p when instance online. blacklist ipv6 in /etc/modprobe.d/blacklist.conf not working either...Any ideas how to disable ipv6 for cloud instance?

@frennkie
Copy link

frennkie commented Oct 9, 2021

@No0key it appears that there is also a Grub line (source: https://www.linuxbabe.com/ubuntu/disable-ipv6-on-ubuntu) Caution: I did not test/try this: GRUB_CMDLINE_LINUX="ipv6.disable=1" or GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1" (https://askubuntu.com/questions/1046057/disabling-ipv6-in-ubuntu-server-18-04)

@No0key
Copy link

No0key commented Oct 20, 2021

@frennkie thanks for the reply. I've tried grub line and that not worked for me on ubuntu20.04 (can't connect to my server). I've found cause of my problem. If any ipv6 settings is used in your config file, ipv6 will be enabled. Since this pull request, networkd just ignores what in sysctl.conf. Solution that worked for me is remove all ipv6 configuration from netplan.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment