Here’s a sample /etc/netplan config for Ubuntu 18.04. HUGE LIFE PRO TIP: against all expectations of decency, netplan refuses to function if you don’t indent everything exactly the way it likes it and returns incomprehensible wharrgarbl errors like “mapping values are not allowed in this context, line 17, column 15” if you, for example, have a single extra space somewhere in the config.
I wish I was kidding.
Anyway, here’s a sample /etc/netplan/01-config.yaml
with a couple interfaces, one wired and static, one wireless and dynamic. Enjoy. And for the love of god, get the spacing exactly right; I really wasn’t kidding about it barfing if you have one too many spaces for a whitespace indent somewhere. Ask me how I know. >=\
If for any reason you have trouble reading this exact spacing, the rule is two spaces for each level of indent. So the v in “version” should line up under the t in “network”, the d in “dhcp4” should line up under the o in “eno1”, and so forth.
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eno1: dhcp4: no dhcp6: no addresses: [192.168.0.1/24] gateway4: 192.168.0.1 nameservers: addresses: [8.8.8.8, 1.1.1.1] wifis: wlp58s0: dhcp4: yes dhcp6: no access-points: "your-wifi-SSID-name": password: "your-wifi-password"
Wonderfully esoteric. But what is the indentation rule.? How many spaces, tabs, jumps, skips, flits? Or is it a secret?
An example with 2 x NICs statically assigned:
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: networkd
ethernets:
enp0s25:
dhcp4: no
dhcp6: no
addresses:
– 10.1.1.58/24
– 2001:44b8:xxxx:3b10::58/64
gateway4: 10.1.1.1
gateway6: 2001:44b8:xxxx:3b10::1941
nameservers:
addresses:
– 192.231.203.132
– 192.231.203.3
– 2001:44b8:1::1
– 2001:44b8:2::2
routes:
– to: 0.0.0.0/32
via: 10.1.1.1
metric: 100
#
enp4s0:
dhcp4: no
dhcp6: no
addresses:
– 10.1.6.58/24
– 2001:44b8:xxxx:3b60::58/64
gateway4: 10.1.6.1
gateway6: 2001:xxxx:4121:3b10::1941
nameservers:
addresses:
– 192.231.203.132
– 192.231.203.3
– 2001:44b8:1::1
– 2001:44b8:2::2
routes:
– to: 0.0.0.0/32
via: 10.1.6.1
metric: 200
#
The last post didn’t show the indentation. Oh well. Can I send you the .yaml file so you can publish it?
What an utterly infuriating and frustrating design to work with.