networkctl — systemd network status check
💬 "networkctl command"
networkctl is a systemd network status check interface that checks the status of interfaces, links, and routes in systemd-networkd.
It summarizes status, speed, and IP for each interface. It checks the application status of network files (.network).
- Concept: Summarizes status, speed, and IP for each interface.
- Key Features: Checks the application status of network files (.network).
- Advantages: Visualizes carrier·operstate.
- Usage: Enables integrated queries for DNS·routing.
Installation and Download
networkctl can be installed via the package manager or an official script.
| Environment | Command |
|---|---|
| Built into systemd | networkctl status |
| Activation | sudo systemctl enable --now systemd-networkd |
| Configuration File Location | /etc/systemd/network/*.network |
| Verification | networkctl --version |
Verify the installation using networkctl --version.
Frequently Used Options
| Option | Description |
|---|---|
| networkctl status | Summarizes all interfaces |
| networkctl status <iface> | Shows details for a specific interface |
| networkctl list | Lists interfaces |
| networkctl renew <iface> | Renews the DHCP lease |
| networkctl query <domain> | DNS/route query (delegates to resolvectl) |
3 Essential Command Combinations
networkctl status eth0— Check detailed status of eth0networkctl list— List all interfacesnetworkctl renew eth0— Renew DHCP lease
💬 "Show me an example of using networkctl on an actual server"
Here's a sequential summary of common scenarios encountered on a production server.
Step 1 · Verify Installation
Check the activation status of systemd-networkd.
networkctl --version && systemctl status systemd-networkd
Step 2 · Check Interface
Check the status of eth0.
networkctl status eth0
Step 3 · List Check
View all interfaces.
networkctl list
Actual Execution Screen
This is the result of checking eth0 status using networkctl status.
!networkctl command execution result
Production Server
How It's Used in Practice
1. Post-boot Network Diagnostics
Situation — Check the status when the IP isn't acquired after booting.
networkctl status eth0
Result — If the State is 'configuring', it's waiting for DHCP; if 'carrier', it's a cable issue.
Key Point — You can locate incorrect .network files via the Network File path.
2. DHCP Renewal
Situation — Renew when the IP has changed due to lease expiration.
networkctl renew eth0 && networkctl status eth0
Result — The Address is renewed. It works without restarting the service.
Key Point — systemd-networkd allows renewal without a restart.
Actual Execution Screen
This is the result of checking all interfaces using networkctl list.
!networkctl command execution result 2
Production Server
Important Notes
- networkctl is specific to systemd-networkd. If using NetworkManager, use nmcli.
- An 'unmanaged' state indicates the .network file wasn't matched. Verify the filename and LinkMatcher.
- Depending on the DHCP server, 'renew' may not take effect immediately.
Source (HTML): https://games.aidebatehub.com/programs/linux/network/networkctl.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments