PRECISE MANAGEMENT SYSTEMS LTD
Info@pmsl.com.ng
+234 803 756 8558

Configure Static IP Addresses On Ubuntu 18.04 LTS Server

Posted by: Precise Management Systems Limited
Category: Tutorials

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 describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: yes
     dhcp6: yes

To save your changes, you run the commands below.

sudo netplan apply

Configuring Static IP Addresses With Networkd
To configure a static IP address using the new NetPlan tool, the file should look like this: IPv4 address (192.168.1.2), Gateway (192.168.1.1), DNS Servers (8.8.8.8,8.8.4.4)

Run the commands below to create a new network configuration file

sudo nano /etc/netplan/01-netcfg.yaml

Then configure IPv4 addresses as shown below… take notes of the format the lines are written…

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: no
     dhcp6: no
     addresses: [192.168.1.2/24]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [8.8.8.8,8.8.4.4]

Exit and save your changes by running the commands below

sudo netplan apply

You can add IPv6 addresses line, separated by a comma.. example below.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: no
     dhcp6: no
     addresses: [192.168.1.2/24, ‘2001:1::2/64’]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [8.8.8.8,8.8.4.4]

Save your changes, apply and you’re done.

This is how to set static IP addresses on Ubuntu 18.04 .

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.

Author: Precise Management Systems Limited