4

no way to make the network works on the new ubuntu server. This is the netplan yaml file:

# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config:disabled}
network:
  version: 2
  ethernets:
    enp0s3:
       addresses: [192.168.0.183/24]
       gateway4: 192.168.0.250
       dhcp4: false
       nameservers: 
         addresses: [8.8.8.8,8.8.4.4]
       optional: true

running netplan --debug apply I get:

Error in network definition //etc/netplan/50-cloud-init.yaml line 1 column 1: expected mapping

I'm going crazy, it was so simple before! Why doesn't work? what does it mean this error?

5

removing dhcp4 setting fixed the issue...who knows!

maybe because if you enable the dhcp you have to set it to "true" and if you disable you have to set to "no"? I really hope not!!

debug info completely useless

| improve this answer | |
  • if you add a second device under ethernets, you may be able to configure that new network device to both dhcp4: false and dhcp6: false. in other words, it may be the initial network device which needs DHCP. – noobninja Jan 23 at 21:31
2

a netplan configuration is base on yaml, when looking your configuration. i think the indentation is error because its have 3 space. maybe you can try this

# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config:disabled}
network:
  version: 2
  ethernets:
    enp0s3:expected mapping
      addresses: [192.168.0.183/24]
      gateway4: 192.168.0.250
      dhcp4: false
      nameservers: 
        addresses: [8.8.8.8,8.8.4.4]
      optional: true
| improve this answer | |
0

I always configure for a static ip the "dhcp" with the value of "no" like this dhcp4: no

See an example below

network:
    ethernets:
        enp0s3:
            dhcp4: no
            dhcp6: no
            addresses: [10.4.1.174/21]
            gateway4: 10.5.1.6
            nameservers:
                addresses: [8.8.4.4,8.8.8.8]
            routes:
                - to: 192.168.0/24
                  via: 10.5.0.1
                  metric: 100
    version: 2
| improve this answer | |
0

My first time coming across this new way of networking and the "expected mapping" error. It's a nice one.

I got a static IP working by editing etc/netplan/50-cloud-init.yaml but found that it was SUPER picky about the layout (spaces).

I used the examples given at

https://netplan.io/examples

By going to the line BEFORE the line mentioned in the error (given when it didn't work) and pressing "return", a new line and the correct amount of indent was automatically inserted.

Restated... I had an error reported in line 12, so I went to the end of line 11 and pressed "return". A carriage return AND the (presumably) correct amount of indentation was automatically inserted.

If the error was at line 1 (as for the OP) I can only guess that the syntax is wrong.

| improve this answer | |
  • Thank you for your contribution! While we do accept links to outside sources, we must acknowledge that they too frequently get changed, moved, or deleted. For this reason, we ask that any links to outside sources are adequately summarized here so that the answer stands alone even if the resource is inaccessible. Please edit your question to adequately summarize the outside resource that you've linked. If you would like more info about our Q&A format and housekeeping rules, please research our help pages. – Nmath Jul 28 '19 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.