Canada  united states of america usa  linkedinfacebook   Call Us Today: 866.646.6461

Configure network in Ubuntu 18

ubuntu10The network configuration has changed in Ubuntu 18 from all the previous versions. The new version uses Netplan and it is somewhat harder if you don't know yaml. The discussion for pros and cons of this move by Ubuntu can be infinite (why change what's working; this is a tool, I don't want to learn the new ways, etc.), but this is a quick tutorial for quickly changing the IP address. (There's more information available on Netplan)

The network configuration files are located in /etc/netplan. Configuration file can be opened as below:

vim /etc/netplan/50-cloud-init.yaml

With comments removed, this is the configuration data for a simple DHCP setup:

network:
ethernets:
enp0s3:
dhcp4: true
version: 2

If you would like to setup a static IP, these are the options to use:

network:
ethernets:
enp0s3:
addresses: [172.16.0.15/24]
  gateway4: 172.16.0.1
dhcp4: no
nameservers:
addresses: [172.16.0.1,8.8.8.8]
optional: true
version: 2

In the above example:

IP address: 172.16.0.15

Gateway: 172.16.0.1

DNS: 172.16.0.1, 8.8.8.8

No network or broadcast address needed. Subnet address is specified in the IP itself (ie: 172.16.0.15/24)

Reboot the server or restart the network by applying the configuration:

netplan apply

ALT IT Consulting is an IT Support company that provides assistance to clients with any technology issues, including Linux, Windows and Mac systems.

Last updated Mar 17, 2019