1

yaml setup I have the following netplan layout and it keeps coming up with the error

IP address shown here as xxx

ethernets: check indentation^

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s8:
    addresses: [xxx.xxx.xxxx.xxx/xx]
    gateway4: xxx.xxx.xxx.xxx
    nameservers:
      addresses: [8.8.8.8,x.x.x.x]

As far as I am aware the spacing is all correct. (2 spaces for each indent) Not sure what I am missing.

Any assistance greatly appreciated

1
  • @steeldriver everything after enp0s8: in fact.
    – Jos
    Commented May 22, 2019 at 12:27

2 Answers 2

4

The correct format is:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s8:
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
          addresses: [10.10.10.1, 1.1.1.1]

The correct spacing is found in /usr/share/doc/netplan/examples/static.yaml.

Follow with:

sudo netplan generate
sudo netplan apply
9
  • Hi so to make sure i get this right then under enp0s8 we still follow the indent rules and place the - under the 'p' (2 spaces in) then leave a space for the IP address and then go gateway and nameservers go back under the 'a' in address. Trying that now :)
    – Patdundee
    Commented May 22, 2019 at 12:38
  • still comes up with the followin "Error in network definition. Expected Mapping (check indentation) ethernets:^
    – Patdundee
    Commented May 22, 2019 at 12:50
  • The - goes under the second d in 'addresses.' Then one space and then the actual address. Are you using the spacebar or tab? Netplan won't accept tabs. What is the result of: sudo netplan generate --debug ?
    – chili555
    Commented May 22, 2019 at 13:12
  • I have it half running now where the debug is fine. It was also reading in the static.yaml and the 50-cloud which were set incorrect so i have deleted these and also added dhcp4: no in the cfg. The netplan has now been generated and applied without issue. Once I connect the network cable it will ping itself only. It will not ping anything else on the network or its gateway or anything on the internet. This is frustrating but i do not which to use the old ifup/down and need to get my head around this :)
    – Patdundee
    Commented May 22, 2019 at 13:41
  • I would certainly try a reboot. Without knowing the addresses, at least the last part; e.g. xxx.xxx.12.1 or xxx.xxx.12.155/24, etc. it is hard to troubleshoot further.
    – chili555
    Commented May 22, 2019 at 13:51
0

What also helped me:

  • using yamllint to identify obvious YAML formatting errors.

    • sudo apt-get install yamllint

    • yamllint /etc/netplan/00-installer-config.yaml

    • Errors like trailing whitespace and extra blank lines can cause issues too

  • Comparing the example at /usr/share/doc/netplan/examples/static.yaml and my config at /etc/netplan/00-installer-config.yaml

    • vimdiff /usr/share/doc/netplan/examples/static.yaml /etc/netplan/00-installer-config.yaml

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .