I have just started testing Ubuntu 18.04 . The first thing I noticed was how different it handles network interfaces. The way Ubuntu manages network interfaces has completely changed.
Have you heard of NetPlan? Probably not, if you have, then you’re a step ahead of many. NetPlan is a new network configuration tool introduced in Ubuntu 17.10 to manage network settings.
It can be used write simple YAML description of the required network interfaces with what they should be configured to do; and it will generate the required configuration for a chosen renderer tool.
This new tool replaces the static interfaces (/etc/network/interfaces) file that had previously been used to configure Ubuntu network interfaces. Now you must use /etc/netplan/*.yaml to configure Ubuntu interfaces.
The new interfaces configuration file now lives in the /etc/netplan directory. There are two renderers. NetworkManager and networkd.
NetworkManager renderer is mostly used on desktop computers and networkd on servers. If you want NetworkManager to control the network interfaces, use NetworkManager as the renderer, otherwise use networkd.
When you use NetworkManager as the renderer, you will use the NetworkManager GUI to manage the interfaces.
Below is a sample file for a network interface using networkd as renderer using DHCP…. Networkd uses the command line to configure the network interfaces.
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# 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:
ethernets:
enp0s3:
addresses: []
dhcp4: true
version: 2
To save your changes, you run the commands below.
sudo netplan apply
Configuring Static IP Addresses with Networkd (Server)
To configure a static IP address using the new NetPlan tool on Ubuntu server, the file should look similar to the content below…
For example you might find a default netplan configuration file in the /etc/netplan directory called 50-cloud-init.yaml with a following content using the networkd deamon to configure your network interface via DHCP…..
sudo nano /etc/netplan/50-cloud-init.yaml
Then file should look like this one below:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# 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:
ethernets:
enp0s3:
addresses: []
dhcp4: true
version: 2
The above is a default networkd redenrer configuration file for a Ubuntu server using DHCP IP configuration…. If you want to setup a static IP address, configure the file as shown below
sudo nano /etc/netplan/50-cloud-init.yaml
Then configure IPv4 addresses as shown below… take notes of the format the lines are written…
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# 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:
ethernets:
enp0s3:
addresses: [192.168.1.2/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
Exit and save your changes by running the commands below
sudo netplan apply
You can add IPv6 addresses line, separated by a comma.. highlighted example below.
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# 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:
ethernets:
enp0s3:
addresses: [192.168.1.2/24]
gateway4: 192.168.1.1
nameservers:
[192.168.1.2/24, '2001:1::2/64']
dhcp4: no
version: 2
Save your changes, apply and you’re done.
Save and apply your changes…
sudo netplan apply sudo netplan --debug apply
This is how to set static IP addresses on Ubuntu 18.04 and 18.10 server and desktop… .
For more about NetPlay, visit this site.
Configure Network Interfaces with NetworkManager
NetworkManager sample configuration file.
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
Next, open the network interfaces GUI on Ubuntu to manage the network.
Congratulations! You’ve just successfully configured static IP addresses on Ubuntu servers.
Enjoy!~
You may also like the post below:
Fix File Upload Issues with WordPress Running on Nginx on Ubuntu
Yeah well it didnt work did it
for me it dint! But thanks for the post though!
After new clean installation of 18.4 server one gets two networking config files: /etc/netplan/50-cloud-init.yaml and /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg. What is the relation between them?
You need to configure all the networking here:
/etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
then cloud-init rewrites /etc/netplan/50-cloud-init.yaml with the new config
you need to do this:
cloud-init clean
in order to make efective the changes.
Krgrds,
Guillermo
This is what worked for me:
EDIT: /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
> network:
> ethernets:
> enp0s3:
> addresses: [192.168.1.125/24]
> gateway4: 192.168.1.1
> nameservers: [8.8.8.8, 8.8.4.4]
> dhcp4: false
> version: 2
I would like to know about the bonding feature in netplan
I just removed cloud-init after a fresh Ubuntu 18.04 install without any issue, I’ll never know if cloud-init is useful or not…
You know what would be mighty useful? When you say to open something you actually give the command to do it.
Yes, I could slug through multiple GIS to find out how to do it, but I used GIS to get to this page in the hopes that you would actually give complete instructions.
Hi,
thank you
My Question :
how to add Permanent Route by Ubuntu 18 LTS ?
Thanks
Nowhere in this how-to article do you specify an actual file name for the new method. Was that intentional because it kinda makes the whole article useless without it.
Точно, бесполезная статья, нигде не описано, как открыть сам файл, с помощью какой команды
sud nano /etc/netplan/01-netcfg.yaml
How to make it work?
##
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
addresses: [ 10.1.10.20/24 ]
gateway4: 10.1.10.1
nameservers:
addresses:
– “192.168.0.5”
– “192.168.0.6”
vlans:
vlan.115:
id: 115
link: enp1s0
addresses:
– 10.1.15.5/25
– 10.1.15.6/25
– 10.1.15.7/25
– 10.1.15.8/25
gateway4: 10.1.15.1
How about you try to follow the instructions? Your edits do not follow the structure of the doc as indicated.
@!robot – are there any plans on fixing this? This website is mentioned in a lot of places and this method is just wrong with the standard Ubuntu server 18.04 install.
Not true. these instructs worked exactly as indicated in a standard fresh installation of Ubuntu 18.04.1.
Thanks a lot, it works!
I was wondered by the network-manager and /etc/network/interfaces that wont work well 😀
just went to edit the network address” sudo nano /etc/netplan/01-netcfg.yaml” but the page was blank so nothing to edit and I know the ip is “192.168.1.6” so where do I actually configure the static IP for my server ?
how stupidity is ubuntu simple ip configuring takes lots of steps…???
how to i will create ip broadcast in Ubuntu 18 ?
please answer
This is all worthless – no explanation on the new lines, if the ‘addresses’ is supposed to be a subnet (although looks like it), and then how to specify ONE ipv4 address per box.
The search for real instructions continues (maybe), or just scrapping ubuntu for good. This is complete BS the way they keep changing things. Redhell is better than this…
Hi everyone,
first of all thanks !Robot for investing your time and sharing your knowledge.
I actually found a solution for Ubuntu 18.04 Server running on Virtualbox.
I hope it helps some of you guys. 🙂
Please vote if so. 😀
https://unix.stackexchange.com/questions/457064/how-do-i-assign-ubuntu-18-04-a-static-ip-its-in-a-virtual-machine-using-vmware/457240#457240
awful unnecessary new method…too bad
is it me or should the address be addresses: 192.168.1.2/32 … instead of addresses: 192.168.1.2/24 … the latter is a range and we are describing an address for an interface.
You’re not describing the range, you’re describing the netmask of the address. /24 describes it as 192.168.1.2 with netmask 255.255.255.0
Who ever came up with this Format, needs to take a stop and think.
I liked the KISS format better.
PS I’ll be surprised if you post this
Steve
Works a treat, thanks 🙂
Don’t know what issues all these other people are having. Not going there….
Worked great, once I recalled how sensitive yaml is to white space. An unnecessary change, but it’s easy enough. Thanks for the post!
its more easy with examples :
/usr/share/doc/netplan.io/examples/windows_dhcp_server.yaml
/usr/share/doc/netplan.io/examples/source_routing.yaml
/usr/share/doc/netplan.io/examples/static_multiaddress.yaml
/usr/share/doc/netplan.io/examples/loopback_interface.yaml
/usr/share/doc/netplan.io/examples/direct_connect_gateway.yaml
/usr/share/doc/netplan.io/examples/vlan.yaml
/usr/share/doc/netplan.io/examples/bonding.yaml
/usr/share/doc/netplan.io/examples/network_manager.yaml
/usr/share/doc/netplan.io/examples/bonding_router.yaml
/usr/share/doc/netplan.io/examples/bridge.yaml
/usr/share/doc/netplan.io/examples/static.yaml
/usr/share/doc/netplan.io/examples/bridge_vlan.yaml
/usr/share/doc/netplan.io/examples/wireless.yaml
else it is a lot of tricks
Well, it worked for me, like a champ.
Thanks