0

So, I am trying to set a static IP address for my Ubuntu Server 18.04.1 LTS. I took the ethernet config from this site.

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.0.1/24]
      gateway4: 192.168.0.1
        nameservers:
          addresses: [192.168.0.1,8.8.8.8]

I carefully made sure there a space between each colon, didn't use tabs and made sure there's no leading spaces at the end of each line. Yet, when I run netplan --debug generate, I get:

Invalid YAML at /etc/netplan/01-network-card.yaml line 9 column 19: mapping values are not allowed in this context

Then, I compared the config with some other sample configs (1, 2, 3) and didn't notice much difference.

I also tried putting the addresses as:

addresses: [ "192.168.0.1/24" ]

As seen in this config with no luck. Whatever I try, it seems that the gateway4 line is always the problem. What am I doing wrong here?

  • 1
    It's the indentation of nameservers that's the problem, I think? – steeldriver Jan 30 at 3:06
  • Ohh, so I guess it thought nameservers was part of that same line. Yep, that was it. Thanks! – Kevin Jan 30 at 3:12

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.