Link to home
Start Free TrialLog in
Avatar of Irwin W.
Irwin W.Flag for Canada

asked on

Netplan static configuration issue

I just installed Ubuntu server 18 and trying to get netplan to take my static IP but not having luck.

Can someone assist me with this?

This what I entered but it's not working.

User generated image
Avatar of David Favor
David Favor
Flag of United States of America image

An netplan... the bane of my existence...

The likely problem is you're working on the wrong file.

The file you posted has no path information. Looks like it's an /etc/netplan file which aren't used when booting Ubuntu.

What is used are netplan files owned by systemd... which usually live in...

/etc/systemd/network/50-default.network

Open in new window


At least that's where they live on machines provisioned by OVH.

The actual location of the file you'll be changing can be found via...

find /etc -type f -exec egrep -il 192.168.28.13 {} \;

Open in new window


So as usual, systemd mucks up logic.
Avatar of Irwin W.

ASKER

Thanks for that.  

The file I modified was located in /etc/netplan

50-cloud-init.yaml

This was the only place the ip I tried to set was found.
If you have 50-cloud-init.yaml this means you're running inside some container system, like LXD rather than at machine level.

Note: You must never, ever, ever modify 50-cloud-init.yaml because APT (package system) owns this file.

This file changes often, as Netplan is newish + changing a great deal right now.

If you modify this file, during updates you'll be asked if APT can over write this file...

1) If you say no (to keep your modifications), there's a good chance your container will brick - networking will die.

2) If you say yes, then your changes will be over written - networking will also die.

Instead of modifying system owned files (always a super bad idea), create a 60-public-init.yaml file with the contents similar to...

network:
    version: 2
    ethernets:
        eth0:
          addresses:
          - x.x.x.x/32

Open in new window


This way your networking will always survive package updates.

Tip: I notice you're using a /24 IP block which is 254 addresses or an entire Class C Network.

If this is correct, then use /24 if you only have a single IP (far more likely), use /32 or many subtle problems will occur.
ASKER CERTIFIED SOLUTION
Avatar of Irwin W.
Irwin W.
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for that info.  For now, I have reverted to Ubuntu 16.04 and can easily muddle my way through changing of the IP address.

Will review my use and understanding of netplan some time in the near future