Fedora Linux users can display and change network interface settings using the `nmcli` command-line tool. If you are wondering what command line tool can you use in fedora linux to display and change network interface settings, the answer is `nmcli`, which is part of NetworkManager. This tool gives you full control over your network connections without needing a graphical interface.
What Command Line Tool Can You Use In Fedora Linux To Display And Change Network Interface Settings
`nmcli` is a powerful command-line utility that comes pre-installed with Fedora. It lets you view, add, modify, activate, and deactivate network connections. You can manage both wired and wireless interfaces directly from the terminal. This tool is ideal for servers, headless systems, or users who prefer the command line.
Understanding Nmcli Basics
Before diving into commands, you need to know that `nmcli` works with NetworkManager. NetworkManager is the default network service in Fedora. It handles all network interfaces and connections. `nmcli` is the command-line front-end for this service.
To check if NetworkManager is running, use:
systemctl status NetworkManager
If it is not active, start it with:
sudo systemctl start NetworkManager
Displaying Network Interface Settings
To see all network interfaces on your Fedora system, run:
nmcli device status
This shows a table with device names, types, states, and connections. For example, you might see `eth0` for Ethernet or `wlan0` for Wi-Fi.
For detailed information about a specific interface, use:
nmcli device show eth0
This displays IP addresses, MAC address, DNS servers, and more. You can also view all connections with:
nmcli connection show
This lists saved network profiles. Each profile has a name and UUID. To see details of a connection profile:
nmcli connection show "My Connection"
Changing Network Interface Settings
You can modify settings using `nmcli`. For example, to change the IP address of an interface:
sudo nmcli connection modify "My Connection" ipv4.addresses 192.168.1.100/24
To set a static IP instead of DHCP:
sudo nmcli connection modify "My Connection" ipv4.method manual
Then add the gateway:
sudo nmcli connection modify "My Connection" ipv4.gateway 192.168.1.1
Set DNS servers:
sudo nmcli connection modify "My Connection" ipv4.dns 8.8.8.8
After changes, restart the connection:
sudo nmcli connection down "My Connection" && sudo nmcli connection up "My Connection"
Managing Wi-Fi Connections
To scan for available Wi-Fi networks:
nmcli device wifi list
Connect to a network:
sudo nmcli device wifi connect "NetworkName" password "YourPassword"
If you need to connect to a hidden network:
sudo nmcli device wifi connect "HiddenNetwork" password "pass" hidden yes
To disconnect from Wi-Fi:
sudo nmcli device disconnect wlan0
Working With Ethernet Interfaces
For wired connections, you can enable or disable an interface:
sudo nmcli device connect eth0
sudo nmcli device disconnect eth0
To change the MAC address of an Ethernet interface:
sudo nmcli connection modify "Wired Connection" 802-3-ethernet.cloned-mac-address 00:11:22:33:44:55
Set the interface to use DHCP:
sudo nmcli connection modify "Wired Connection" ipv4.method auto
Creating New Connections
You can create a new connection profile from scratch. For a static Ethernet connection:
sudo nmcli connection add type ethernet con-name "StaticEth" ifname eth0 ipv4.addresses 10.0.0.2/24 ipv4.gateway 10.0.0.1 ipv4.dns 10.0.0.1 ipv4.method manual
For a dynamic DHCP connection:
sudo nmcli connection add type ethernet con-name "DHCPEth" ifname eth0 ipv4.method auto
To create a Wi-Fi connection profile:
sudo nmcli connection add type wifi con-name "MyWiFi" ifname wlan0 ssid "NetworkName" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "YourPassword"
Deleting And Disabling Connections
Remove a connection profile:
sudo nmcli connection delete "ConnectionName"
To disable a network interface temporarily:
sudo nmcli device disconnect eth0
Re-enable it with:
sudo nmcli device connect eth0
Using Nmcli With Scripts
`nmcli` is scriptable. You can use it in bash scripts to automate network tasks. For example, to check if a connection is active:
if nmcli -t -f GENERAL.STATE device show eth0 | grep -q "connected"; then
echo "Ethernet is connected"
fi
You can also monitor network changes:
nmcli monitor
This shows real-time events like connection changes and device status updates.
Alternative Tools For Network Management
While `nmcli` is the primary tool, Fedora also offers other command-line utilities. `ip` command from the iproute2 package can display and change interface settings. For example:
ip addr show
ip link set eth0 up
But `ip` does not manage NetworkManager connections. It works directly with the kernel. For persistent changes, `nmcli` is better.
Another tool is `nmtui`, which is a text-based user interface for NetworkManager. Run it with:
sudo nmtui
It provides a menu-driven interface for managing connections. However, for automation and scripting, `nmcli` is superior.
Troubleshooting Common Issues
If `nmcli` commands fail, check that NetworkManager is running. Use:
systemctl is-active NetworkManager
If the service is inactive, enable and start it:
sudo systemctl enable --now NetworkManager
Sometimes changes do not take effect immediately. Restart the network service:
sudo systemctl restart NetworkManager
If you cannot see wireless networks, ensure your Wi-Fi adapter is not blocked. Check with:
rfkill list
Unblock it with:
sudo rfkill unblock wifi
For permission issues, run `nmcli` with `sudo` for modification commands.
Advanced Configuration With Nmcli
You can configure bonding, bridging, and VLANs using `nmcli`. For example, to create a bridge:
sudo nmcli connection add type bridge con-name "br0" ifname br0
sudo nmcli connection add type bridge-slave con-name "br0-slave" ifname eth0 master br0
To set up a VLAN:
sudo nmcli connection add type vlan con-name "vlan10" ifname eth0.10 vlan.parent eth0 vlan.id 10 ipv4.addresses 192.168.10.1/24 ipv4.method manual
You can also configure teaming (link aggregation) with `nmcli`.
Viewing Connection History And Logs
To see connection logs:
journalctl -u NetworkManager
This shows recent events and errors. For real-time logs:
journalctl -u NetworkManager -f
You can also check the status of all devices:
nmcli general status
This shows the overall NetworkManager state.
Using Nmcli In Rescue Or Minimal Environments
Even in rescue mode or minimal Fedora installations, `nmcli` is available. If it is not installed, add it with:
sudo dnf install NetworkManager
Then start the service. This makes `nmcli` usable even without a full desktop environment.
Comparing Nmcli With Other Distros
Fedora uses NetworkManager by default, so `nmcli` works similarly on other distributions like CentOS, RHEL, and Ubuntu (with NetworkManager installed). The commands are almost identical. This makes `nmcli` a portable skill across Linux systems.
Best Practices For Using Nmcli
Always verify changes with `nmcli connection show` or `nmcli device show`. Use descriptive connection names to avoid confusion. Backup connection profiles before making major changes:
sudo nmcli connection export "ConnectionName" > backup.nmconnection
Restore with:
sudo nmcli connection import type ethernet file backup.nmconnection
Test changes in a non-production environment first if possible.
Common Nmcli Command Examples
- List all devices: `nmcli device status`
- Show IP configuration: `nmcli device show eth0`
- Connect to Wi-Fi: `nmcli device wifi connect SSID password PASSWORD`
- Change to static IP: `nmcli connection modify “Name” ipv4.method manual ipv4.addresses 192.168.1.10/24`
- Restart connection: `nmcli connection down “Name” && nmcli connection up “Name”`
- Delete connection: `nmcli connection delete “Name”`
- Enable interface: `nmcli device connect eth0`
Frequently Asked Questions
What Is The Difference Between Nmcli And Ip Command?
`nmcli` manages NetworkManager connections and profiles. The `ip` command configures network interfaces directly in the kernel. `nmcli` changes persist across reboots, while `ip` changes are temporary. For permanent network configuration in Fedora, use `nmcli`.
Can I Use Nmcli Without Sudo?
You can view settings without `sudo`, but changing settings requires root privileges. Use `sudo` for any modification commands.
How Do I Reset A Network Interface To Defaults?
Delete the connection profile and recreate it. For example: `sudo nmcli connection delete “Wired Connection”` then `sudo nmcli connection add type ethernet ifname eth0`. Or use `sudo nmcli connection modify “Name” ipv4.method auto` to revert to DHCP.
Does Nmcli Work With VPNs?
Yes, `nmcli` can manage VPN connections. Use `nmcli connection import type vpn file config.ovpn` for OpenVPN files. You can also create VPN connections manually.
Why Is My Wifi Not Showing In Nmcli Device Wifi List?
Ensure your Wi-Fi adapter is not blocked by `rfkill`. Also check that NetworkManager is running and the driver is loaded. Use `lspci` or `lsusb` to verify the hardware is detected.
Conclusion
Fedora Linux users can display and change network interface settings using the `nmcli` command-line tool. This utility provides complete control over network connections from the terminal. Whether you need to configure static IPs, connect to Wi-Fi, or troubleshoot issues, `nmcli` is the go-to tool. Practice the commands in this guide to master network management on Fedora. With `nmcli`, you can handle any network task efficiently without needing a graphical interface.