Network configuration on ubuntu
May 18, 2025Less than 1 minute
Netplan on Ubuntu is a network configuration tool introduced in Ubuntu 17.10 (Artful Aardvark) and widely used in subsequent versions. It simplifies network setup by allowing administrators to define network interfaces and their configurations in YAML files, which are then applied to the system using a backend renderer (such as systemd-networkd or NetworkManager).
sudo vi /etc/netplan/50-cloud-init.yaml
network:
version: 2
# networkd is for server environments with static/fixed configurations.
# NetworkManager is for for desktop/laptop environments with dynamic networks (e.g., Wi-Fi, VPNs).
renderer: networkd
ethernets:
# ip link show
enp0s5:
dhcp4: no
# static addresses
addresses:
- 10.211.55.100/24
# gateway
routes:
- to: default
- via: 10.211.55.1
# dns
nameservers:
addresses:
- 8.8.8.8
sudo netplan try
sudo netplan apply