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 new release of systemd which is present in Ubuntu 18.04. It displays the state of the network links as seen by systemd-networkd.

Read Also: A Linux Sysadmin’s Guide to Network Management, Troubleshooting and Debugging

Note: Before running networkctl, ensure that systemd-networkd is running, otherwise you will get incomplete output indicated by the following error.

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 ● systemd-networkd.service - Network Service Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled) Active: active (running) since Tue 2018-07-31 11:38:52 IST; 1s ago Docs: man:systemd-networkd.service(8) Main PID: 13682 (systemd-network) Status: "Processing requests..." CGroup: /system.slice/systemd-networkd.service └─13682 /lib/systemd/systemd-networkd Jul 31 11:38:52 TecMint systemd[1]: Starting Network Service... Jul 31 11:38:52 TecMint systemd-networkd[13682]: vmnet8: Gained IPv6LL Jul 31 11:38:52 TecMint systemd-networkd[13682]: vmnet1: Gained IPv6LL Jul 31 11:38:52 TecMint systemd-networkd[13682]: enp1s0: Gained IPv6LL Jul 31 11:38:52 TecMint systemd-networkd[13682]: Enumeration completed Jul 31 11:38:52 TecMint systemd[1]: Started Network Service.

If systemd-networkd is not running, you can start and enable it to start at boot time using following commands.

$ sudo systemctl start systemd-networkd $ sudo systemctlenable systemd-networkd

To get the status information about your network links, run the following networkctl command without any argument.

$ networkctl IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 enp1s0 ether routable unmanaged 3 wlp2s0 wlan off unmanaged 4 vmnet1 ether routable unmanaged 5 vmnet8 ether routable unmanaged 5 links listed.

To display all network links and their status, use the -a flag.

$ networkctl -a IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 enp1s0 ether routable unmanaged 3 wlp2s0 wlan off unmanaged 4 vmnet1 ether routable unmanaged 5 vmnet8 ether routable unmanaged 5 links listed.

To get a list of existing links and their status, use the list command (equivalent to using the -a flag) as shown.

$ networkctl list IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 enp1s0 ether routable unmanaged 3 wlp2s0 wlan off unmanaged 4 vmnet1 ether routable unmanaged 5 vmnet8 ether routable unmanaged 5 links listed.

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 ● State: routable Address: 192.168.0.103 on enp1s0 172.16.236.1 on vmnet1 192.168.167.1 on vmnet8 fe80::8f0c:7825:8057:5eec on enp1s0 fe80::250:56ff:fec0:1 on vmnet1 fe80::250:56ff:fec0:8 on vmnet8 Gateway: 192.168.0.1 (TP-LINK TECHNOLOGIES CO.,LTD.) on enp1s0

OR

$ networkctl status enp1s0 ● 2: enp1s0 Link File: /lib/systemd/network/99-default.link Network File: n/a Type: ether State: routable (unmanaged) Path: pci-0000:01:00.0 Driver: r8169 Vendor: Realtek Semiconductor Co., Ltd. Model: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller HW Address: 28:d2:44:eb:bd:98 (LCFC(HeFei) Electronics Technology Co., Ltd.) Address: 192.168.0.103 fe80::8f0c:7825:8057:5eec Gateway: 192.168.0.1 (TP-LINK TECHNOLOGIES CO.,LTD.)

To show LLDP (Link Layer Discovery Protocol) status, use the lldp command.

$ networkctl lldp

By default, the output of networkctl is piped into a pager, you can prevent this by adding the –no-pager flag.

$ networkctl --no-pager

You can also print output without column headers and the footer using the --no-legend option.

$ networkctl --no-legend

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:

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.