Network Configuration Tools On Ubuntu Server
Network Configuration Tools on Ubuntu Server (Netplan)
- netplan Netplan is the default network configuration utility in Ubuntu (since 17.10), using YAML files for configuration.
Description Reads /etc/netplan/*.yaml files to configure network interfaces.
Generates backend configurations for systemd-networkd or NetworkManager.
Usage & Syntax bash sudo netplan [command] [options] Commands Command Description apply Apply the current Netplan configuration. generate Generate backend configuration files (without applying). try Apply a configuration with a timeout (reverts if not confirmed). get Retrieve a specific configuration value. set Modify a configuration value. info Show debug information. Examples bash
Apply Netplan configuration
sudo netplan apply
Generate configuration (dry run)
sudo netplan generate
Try a new config (reverts after 120s if not confirmed)
sudo netplan try
- ip (from iproute2) A powerful tool for network interface and routing management (replaces ifconfig and route).
Description Used to manage interfaces, IP addresses, routes, and ARP tables.
Usage & Syntax bash ip [OPTIONS] OBJECT {COMMAND | help} Common Objects Object Description link Manage network interfaces. addr Manage IP addresses. route Manage routing tables. neigh Manage ARP/NDISC cache. Examples bash
Show all interfaces
ip link show
Assign an IP address
sudo ip addr add 192.168.1.100/24 dev eth0
Show routing table
ip route show
Add a default gateway
sudo ip route add default via 192.168.1.1
- nmcli (NetworkManager Command Line) Used if NetworkManager is installed (common on desktops, optional on servers).
Description Controls NetworkManager for managing network connections.
Usage & Syntax
bash
nmcli [OPTIONS] OBJECT {COMMAND | help}
Common Commands
Command Description
nmcli connection show List all connections.
nmcli device status Show device status.
nmcli connection up/down
List all connections
nmcli connection show
Bring up a connection
sudo nmcli connection up “Wired Connection 1”
- systemd-networkd (if used as Netplan backend) A system daemon that manages network configurations (alternative to NetworkManager).
Description Used when Netplan is configured with renderer: networkd.
Usage & Syntax bash systemctl [start|stop|status] systemd-networkd Examples bash
Check status
systemctl status systemd-networkd
Restart network daemon
sudo systemctl restart systemd-networkd
- ss (Socket Statistics) Replaces netstat for monitoring network connections.
Description Displays socket statistics (TCP/UDP connections, listening ports).
Usage & Syntax bash ss [options] Common Options Option Description -t Show TCP sockets. -u Show UDP sockets. -l Show listening sockets. -n Show numeric addresses. Examples bash
Show all listening TCP ports
ss -tuln
- ping Tests network connectivity to a host.
Description Sends ICMP echo requests to check if a host is reachable.
Usage & Syntax
bash
ping [options]
Ping Google’s DNS server
ping 8.8.8.8
- traceroute (or tracepath) Traces the route packets take to a network host.
Description Helps diagnose network routing issues.
Usage & Syntax
bash
traceroute
Trace route to Google
traceroute google.com
- dig (DNS Lookup) Queries DNS servers for domain information.
Description Useful for troubleshooting DNS resolution.
Usage & Syntax
bash
dig [options]
Query A record for google.com
dig google.com
- hostnamectl Manages the system hostname.
Description Sets or displays the system hostname.
Usage & Syntax
bash
hostnamectl [set-hostname
Set a new hostname
sudo hostnamectl set-hostname myserver
- resolvectl (DNS Resolution) Manages DNS resolution (part of systemd-resolved).
Description Queries or configures DNS settings.
Usage & Syntax
bash
resolvectl [query|status]
Check DNS status
resolvectl status
Query a domain
resolvectl query google.com Summary Table Tool Purpose Example Command netplan Network config via YAML sudo netplan apply ip Interface & routing ip addr show nmcli NetworkManager control nmcli connection show systemd-networkd Network daemon systemctl restart systemd-networkd ss Socket stats ss -tuln ping Connectivity test ping 8.8.8.8 traceroute Route tracing traceroute google.com dig DNS lookup dig google.com hostnamectl Hostname mgmt hostnamectl set-hostname myserver resolvectl DNS resolution resolvectl status This should cover most of the essential network-related command-line tools on Ubuntu Server with Netplan. Let me know if you need further details! 🚀