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.

netplan
LVL 33
nappy_dThere are a 1000 ways to skin the technology cat.Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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.
nappy_dThere are a 1000 ways to skin the technology cat.Author Commented:
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.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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.
nappy_dThere are a 1000 ways to skin the technology cat.Author Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nappy_dThere are a 1000 ways to skin the technology cat.Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.