This article introduces the network configuration procedure for Ubuntu 26.04 LTS Server. The configuration method differs from Desktop — the steps shown here are for Server. In addition to IPv4, this article also covers IPv6 configuration.
How to Check the Current Network Configuration
You can check the current network configuration with the ip command.
ip aubuntu@ubuntu2604:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:0e:cf:b9 brd ff:ff:ff:ff:ff:ff
altname enx5254000ecfb9
inet 10.100.41.128/22 brd 10.100.43.255 scope global enp1s0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe0e:cfb9/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
ubuntu@ubuntu2604:~$Check the default gateway with ip route, and the DNS server with resolvectl status.
ubuntu@ubuntu2604:~$ ip route
default via 10.100.40.1 dev enp1s0 proto static
10.100.40.0/22 dev enp1s0 proto kernel scope link src 10.100.41.128
ubuntu@ubuntu2604:~$ubuntu@ubuntu2604:~$ resolvectl status
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp1s0)
Current Scopes: DNS
Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.1.0.1
DNS Servers: 10.1.0.1 10.1.0.2
Default Route: yes
ubuntu@ubuntu2604:~$About Netplan
Unlike Desktop, which uses NetworkManager, Ubuntu Server configures the network using a mechanism called Netplan. Netplan reads YAML configuration files placed under /etc/netplan/ and applies the network configuration through its backend, systemd-networkd.
You can check the contents of the configuration file that is generated automatically during installation with the following commands.
root@ubuntu2604:/etc/netplan# pwd
/etc/netplan
root@ubuntu2604:/etc/netplan# cat 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp1s0:
addresses:
- 10.100.41.128/22
match:
macaddress: 52:54:00:0e:cf:b9
nameservers:
addresses:
- 10.1.0.1
- 10.1.0.2
search: []
routes:
- to: default
via: 10.100.40.1
set-name: enp1s0
version: 2
root@ubuntu2604:/etc/netplan#The main items in the configuration file above are as follows.
| Item | Description |
|---|---|
| ethernets | Section specifying the type of interface being configured (wired LAN) |
| enp1s0 | Name of the interface being configured |
| addresses | IP address and subnet mask to assign (CIDR notation) |
| match.macaddress | Specification used to identify the interface by its MAC address |
| nameservers.addresses | IP addresses of the DNS servers |
| nameservers.search | List of DNS search domains (domains automatically appended when resolving hostnames) |
| routes | Routing information (to: default specifies the default route) |
| set-name | Name assigned to the interface identified by match |
| version | Format version of the Netplan configuration file |
How to Configure a Static IPv4 Address
Edit the configuration file to change the IP address, DNS servers, and default gateway.
sudo vi /etc/netplan/00-installer-config.yamlnetwork:
ethernets:
enp1s0:
addresses:
- 10.100.41.200/22
nameservers:
addresses:
- 10.1.0.1
- 10.1.0.2
search:
- kazulog.info
routes:
- to: default
via: 10.100.40.1
version: 2The example above changes the IP address to 10.100.41.200/22. match and set-name are not needed when you specify the interface name directly.
search specifies the DNS search domain. If you set kazulog.info, resolving a hostname alone — for example ping www — will automatically attempt to resolve it as www.kazulog.info.
How to Obtain an IPv4 Address via DHCP
If you want to obtain an IPv4 address automatically from a DHCP server instead of using a fixed IP, set dhcp4 to true.
network:
ethernets:
enp1s0:
dhcp4: true
version: 2How to Configure an IPv6 Address
With Netplan, you can configure IPv6 addresses by adding IPv6-related items under the ethernets section. As with IPv4, you can either specify a static address directly or configure it automatically via DHCPv6 or Router Advertisement (RA).
| Item | Description |
|---|---|
| addresses | IPv6 addresses can be listed in the same addresses item as IPv4 (specified with a prefix length) |
| routes | The IPv6 default route is specified with to: ::/0 |
| nameservers.addresses | IPv6 DNS server addresses can be listed in the same item as IPv4 |
| dhcp6 | Set to true to obtain an address automatically via DHCPv6 |
| accept-ra | Set to true to accept Router Advertisements (RA) and configure an address automatically (enabled by default) |
How to Configure a Static IPv6 Address
network:
ethernets:
enp1s0:
addresses:
- 10.100.41.200/22
- "2001:db8:41::200/64"
nameservers:
addresses:
- 10.1.0.1
- 10.1.0.2
- "2001:db8:1::1"
search:
- kazulog.info
routes:
- to: default
via: 10.100.40.1
- to: "::/0"
via: "2001:db8:41::1"
version: 2The example above configures the static IPv6 address 2001:db8:41::200/64 in addition to the IPv4 address (10.100.41.200/22). The IPv6 default route is specified with to: ::/0, with via set to the IPv6 gateway address.
In the example above, on-link: true is not required because the gateway address specified in via (2001:db8:41::1) falls within the prefix configured on the interface (2001:db8:41::/64), so it is recognized as a valid route without issue. However, when your ISP provides a link-local address (fe80::~) as the gateway, or in other cases where the via address falls outside the interface’s directly connected prefix, you need to add on-link: true to the route.
routes:
- to: "::/0"
via: "fe80::1"
on-link: trueAutomatic IPv6 Address Configuration via DHCPv6 / RA (Router Advertisement)
In environments where the upstream router distributes prefixes via RA (Router Advertisement), simply setting accept-ra to true will configure the IPv6 address automatically (this is often enabled by default, so specifying it explicitly may not be necessary).
network:
ethernets:
enp1s0:
dhcp4: true
accept-ra: true
version: 2In environments that obtain an address from a DHCPv6 server, set dhcp6 to true.
network:
ethernets:
enp1s0:
dhcp4: true
dhcp6: true
version: 2Checking the Configuration File Syntax
Before applying the configuration, you can check the YAML file for syntax errors.
sudo netplan generateIf there is an indentation error or similar issue, an error message is displayed when the command is run.
How to Apply the Configuration
Apply the edited configuration file with netplan apply.
sudo netplan applynetplan try.sudo netplan tryWhen you run netplan try, the configuration automatically rolls back to the previous settings unless you confirm it with a key press within a set amount of time. Verify that the connection is not disconnected, then press Enter to confirm the configuration.
ubuntu@ubuntu2604:~$ sudo netplan try
Do you want to keep these settings?
Press ENTER before the timeout to accept the new configuration
Changes will revert in 118 seconds
Configuration accepted.
ubuntu@ubuntu2604:~$Checking After Applying the Configuration
After running netplan apply, confirm that the new IPv4 address is applied with the ip a command.
ubuntu@ubuntu2604:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:0e:cf:b9 brd ff:ff:ff:ff:ff:ff
altname enx5254000ecfb9
inet 10.100.41.200/22 brd 10.100.43.255 scope global enp1s0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe0e:cfb9/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
ubuntu@ubuntu2604:~$The above is an example confirming that the IP address has been changed to 10.100.41.200/22.
Check the IPv6 address with the ip -6 a command.
ubuntu@ubuntu2604:/etc/netplan$ ip -6 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2001:db8:41::200/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe0e:cfb9/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
ubuntu@ubuntu2604:/etc/netplan$Check the IPv6 default route with the ip -6 route command.
ubuntu@ubuntu2604:/etc/netplan$ ip -6 route
2001:db8:41::/64 dev enp1s0 proto kernel metric 256 pref medium
fe80::/64 dev enp1s0 proto kernel metric 256 pref medium
default via 2001:db8:41::1 dev enp1s0 proto static metric 1024 pref medium
ubuntu@ubuntu2604:/etc/netplan$The above is an example confirming that the IPv6 address is set to 2001:db8:41::200/64, and the default route is via 2001:db8:41::1.