Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 17909  / 1 Year ago, sat, march 11, 2023, 8:06:56

I'm trying to configure a static IP and I keep getting this error when I try and execute the changes:


Invalid YAML: mapping values are not allowed in this context:
network:
^

I've edited my /etc/netplan/00-installer-config.yaml to:


network:
version: 2
ethernets:
eno1:
dhcp4: false
addresses: [192.168.20.6/24]
gateway4: 192.168.20.2
nameservers:
addresses: [8.8.8.8,8.8.4.4,192.168.20.2]

I used this guide for this configuration, but I've also followed a bunch of other guides and each time with same result.


All the other questions I've read that are related to this issue have been some problem to do with incorrect indentation or spacing, but I can't see where I'm going wrong. I've followed a few different examples, and have rewritten the file several times to try and make sure I'm not missing a stray spaces but I'm getting the same result every time.


More From » networking

 Answers
5

Your /etc/netplan/00-installer-config.yaml should look like this. Netplan is very fussy about formatting. Use my .yaml EXACTLY as I show it.



  • 2 space indentation

  • no tabs

  • added "renderer: networkd"

  • "dhcp4: false" is not required, as false is the default

  • brackets around [192.168.20.6/24]

  • spaces after commas in nameservers addresses




network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: [192.168.20.6/24]
gateway4: 192.168.20.2
nameservers:
addresses: [8.8.8.8, 8.8.4.4, 192.168.20.2]

sudo netplan --debug generate


sudo netplan apply


reboot


[#3073] Saturday, March 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taigysel

Total Points: 33
Total Questions: 136
Total Answers: 114

Location: Singapore
Member since Wed, Jan 13, 2021
3 Years ago
taigysel questions
;