Home / Alt manpages / networkctl(1)

  • networkctl(1)
  • User command
  • linux

Read Network State and Apply Changes with networkctl

networkctl gets you from "is this interface actually up" to a controlled reload of a changed .network file in about 10 minutes. Along the way it tells carrier apart from a usable route, and shows exactly what systemd-networkd selected for a device.

Before you start

This guide assumes a system using systemd-networkd. You need networkctl from systemd 219 or newer; the examples here were checked against systemd 255.4. Reading status normally needs no elevated privilege. Changing link state or reloading network configuration normally needs root, so use sudo where shown.

Have the real interface name ready, such as enp0s31f6. Do not copy that name blindly: predictable interface names differ between machines, so find yours first.

1. Find the interface and its high-level state

Start with a complete link list:

networkctl --no-pager list

The columns that matter are the link index and name, then OPERATIONAL and SETUP. A line like this is healthy for a managed Ethernet link:

2 enp0s31f6  ether  routable  configured
  • routable means the link has carrier and a routable address.
  • carrier only means a physical or virtual link is present.
  • no-carrier means the device is powered but has no carrier yet.
  • configured (the setup column) means networkd configured the link; unmanaged means it is not handling it at all. A Docker bridge can be routable and unmanaged without that meaning networkd is broken.

Use a name or index to narrow the output:

networkctl --no-pager list enp0s31f6

Checkpoint

You have the exact interface name, and you know whether the problem is link carrier, networkd setup, or something higher up such as DNS.

Ask for details about the selected interface:

networkctl --no-pager status enp0s31f6

The report can include the selected link and network files, driver, hardware address, MTU, operational state, addresses, gateway, DNS servers, and recent networkd log lines. Leave off the link argument and status reports the combined network state instead:

networkctl --no-pager status

The overall report has a State and an Online state. Online status is based on links networkd considers required, so partial does not mean every interface is unusable, it means some required links are online and some are not. If status is long, --lines=20 shows the 20 most recent journal lines, and --full stops long values being shortened:

networkctl --no-pager --full --lines=20 status enp0s31f6

When diagnosing a service outage, compare the address and gateway here with the route and resolver evidence from the application host. A routable interface does not prove that a particular remote service, route policy, or DNS name actually works.

3. Use JSON when a script needs stable fields

Human-readable output is fine at a terminal but awkward to parse. Request compact JSON for a script or a quick inspection:

networkctl --no-pager --json=short status enp0s31f6

For review, use the indented form:

networkctl --no-pager --json=pretty status enp0s31f6

Do not assume a missing field is an error. The local loopback interface, for example, reports no associated network file, and some online-state fields are not meaningful for every interface. Check the exit status as well as the data:

if networkctl --no-pager --json=short status enp0s31f6 >/tmp/networkctl.json; then
    printf '%s\n' 'networkctl completed successfully'
else
    printf '%s\n' 'networkctl could not inspect the interface' >&2
    exit 1
fi

4. Check the configuration selected for a device

cat shows network configuration files known to networkd. For a specific interface, use the @ form:

networkctl --no-pager cat @enp0s31f6

If no file is associated, networkctl says so, which is different from a syntax error. A file can exist in /etc/systemd/network/ but fail to match the interface, or a link can be intentionally unmanaged.

You can also display a named file, if you know it:

networkctl --no-pager cat 10-wan.network

Use this before editing anything. It heads off the common mistake of changing a file that looks plausible but is not the one networkd actually selected.

5. Apply a changed networkd configuration

Editing a .network file and asking only for a reconfigure is a common trap. On systemd 255, reconfigure does not reload changed .network or .netdev files first. The safe sequence is:

sudo networkctl reload
sudo networkctl reconfigure enp0s31f6
networkctl --no-pager status enp0s31f6

reload makes networkd reread .network and .netdev files. New matching network files can reconfigure their interfaces. A new .netdev can create its virtual device, but editing or removing an existing .netdev does not automatically update or remove that device: treat that as a separate operational task.

Warning

Reloading or reconfiguring a live management interface can interrupt SSH, DHCP, routes, or addresses. Keep an existing session open, arrange console access, and make one change at a time. If the result is wrong, restore the previous file and repeat the same reload and reconfigure sequence. Reverting the file is the only undo; networkctl keeps no rollback copy for you.

Checkpoint

Status shows the expected network file and the expected address, gateway, and operational state after the change. If it does not, stop before changing more files and inspect the recent lines:

networkctl --no-pager --lines=30 status enp0s31f6

The commands below change live state and are not needed for ordinary diagnosis:

  • sudo networkctl down DEVICE brings a device down and can cut the current connection.
  • sudo networkctl up DEVICE brings a device up, but does not by itself guarantee correct addressing or routing.
  • sudo networkctl renew DEVICE renews dynamic configuration, such as a DHCP lease.
  • sudo networkctl delete DEVICE deletes a virtual netdev. Never use it on a production bridge or virtual device until you have checked which workloads depend on it.

Use an interface name rather than an uncertain numeric index, and verify the target with networkctl list immediately before a state-changing command. Network topology can change while you are working, so an old index is not a safe identity.

Done means

  • Identified the target interface with networkctl list.
  • Checked both operational state and setup state.
  • Inspected the selected network configuration with networkctl cat.
  • Used JSON only where a script needs machine-readable fields.
  • Reloaded before reconfiguring after an edit, and verified the result.
  • Kept recovery access available before touching a live management link.