networkctl is a command-line utility for viewing a summary of network devices and their connection status. It allows you to query and control the Linux networking subsystem.
It is one of the new commands in the latest release of systemd that displays the state of the network links as seen by the systemd-networkd service.
WARNING: systemd-networkd is not running, output will be incomplete.
You can check the status of systemd-networkd by running the following systemctl command.
sudo systemctl status systemd-networkd
If systemd-networkd is not running, you can start, enable it to start at boot time, and verify the status using the following commands.
sudo systemctl start systemd-networkd sudo systemctl enable systemd-networkd sudo systemctl status systemd-networkd
1. Listing Network Connections in Linux
To get the status information about your all network connections, run the following networkctl command without any argument.
networkctl
The above command will list all the network interfaces along with their statuses.
In the above output, you can see three network interfaces: lo (loopback), enp7s0 (Ethernet), and virbr0 (virtual network). Each interface has information about its index (IDX), name (LINK), type, operational status, and setup status.
2. Listing Active Network Connections in Linux
To display information about the specified links, such as type, state, kernel module driver, hardware and IP address, configured DNS, server, and more, use the status command. If you don’t specify any links, routable links are shown by default.
networkctl status
To list various details of specific network interface called enp7s0
, you can run the following command, which will list network configuration files, type, state, IP addresses (both IPv4 and IPv6), broadcast addresses, gateway, DNS servers, domain, routing information, maximum transmission unit (MTU), and queuing discipline (QDisc).
networkctl status enp7s0
Enable/Disable Network Interface in Linux
You can enable or disable a particular network interface in Linux using the following commands.
To enable (bring up) a network interface:
sudo networkctl up INTERFACE
To disable (bring down) a network interface:
sudo networkctl down INTERFACE
Replace INTERFACE with the name of the network interface.
To view its help message, use the -h
flag or check out its man page for more information.
networkctl -h OR man networkctl
You will also find the following Linux networking guides useful:
- nload – Monitor Linux Network Bandwidth Usage in Real Time
- 10 Useful “IP” Commands to Configure Network Interfaces
- 15 Useful “ifconfig” Commands to Configure Network Interface in Linux
- 12 Tcpdump Commands – A Network Sniffer Tool
That’s all! In this article, we have explained how to use networkctl command for viewing a summary of network devices attached to a Linux system. Use the feedback form below to share your thoughts or ask any questions.
should be