Network configuration Ubuntu - Netplan
In the current version of Ubuntu Server, Ubuntu 18.04 (Bionic Beaver), the network configuration can no longer be set in the file /etc/network/interfaces in a default installation. Since Ubuntu 17.10, there is Netplan, which is a new option to configure network interfaces. The network configuration is stored in .yaml-files. In addition to changes to the configuration of the network interfaces, there are also new configurations regarding the hostname.
Network configuration (static)
sudo rm /etc/netplan/50-cloud-init.yaml sudo touch /etc/netplan/01-ens160.yaml
The content of the file in a static network configuration should look as follows:
network:
version: 2
renderer: networkd
ethernets:
ens160:
dhcp4: no
dhcp6: no
addresses: [10.2.2.123/24]
gateway4: 10.2.2.1
nameservers:
addresses: [192.168.110.50]
Next, the network configuration can be activated:
sudo netplan apply
Note: Please use spaces for indentation in this file and do not use tabs.
Change hostname
In Ubuntu 18.04, it is no longer enough to set the hostname via /etc/hostname or hostnamectl. After a reboot of the server, the hostname would be lost again, as it has not been stored. In the following, it is explained how to permanently set the host name:
nano /etc/cloud/cloud.cfg
# This will cause the set+update hostname module to not operate (if true) preserve_hostname: false
Here, the value preserve_hostname must be set from false to true.
# This will cause the set+update hostname module to not operate (if true) preserve_hostname: true
After that, the hostname can be set permanently using the following commands:
sudo nano /etc/hostname sudo hostnamectl set-hostname web-01
Network configuration (other)
For other network configurations, such as DHCP, Bonds, WLAN etc., you will find corresponding notes on the netplan.io website.
|
Author: Jonas Sterr Jonas Sterr has been working for Thomas-Krenn for several years. Originally employed as a trainee in technical support and then in hosting (formerly Filoo), Mr. Sterr now mainly deals with the topics of storage (SDS / Huawei / Netapp), virtualization (VMware, Proxmox, HyperV) and network (switches, firewalls) in product management at Thomas-Krenn.AG in Freyung.
|
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|


