Configuring network settings in Linux might seem intimidating, but it’s straightforward with the right tools. Here’s how to manage wired/wireless connections using both command-line and graphical methods.
Method 1: Using nmcli
(NetworkManager Command Line)
Best for: Quick changes without GUIs. Works on Ubuntu, Fedora, CentOS, etc.
-
List network interfaces:
nmcli device status
Identify your interface (e.g.,
eth0
for wired,wlan0
for wireless). -
Connect to Wi-Fi:
nmcli device wifi list # Scan networks nmcli device wifi connect [SSID] password [PASSWORD]
-
Set static IP (replace
eth0
,192.168.1.100
, and8.8.8.8
with your values):nmcli con add type ethernet con-name "my-static" ifname eth0 \ ipv4.addresses 192.168.1.100/24 \ ipv4.gateway 192.168.1.1 \ ipv4.dns "8.8.8.8" \ ipv4.method manual
-
Restart the connection:
nmcli con down "my-static" && nmcli con up "my-static"
Method 2: Editing Config Files (Persistent Settings)
Best for: Server environments (Debian/Ubuntu use /etc/network/interfaces
; Fedora/CentOS use /etc/sysconfig/network-scripts/
).
Example for Debian/Ubuntu (/etc/network/interfaces
):
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
Apply changes:
sudo systemctl restart networking
Method 3: GUI Tools (Desktop Users)
-
Ubuntu:
- Open
Settings
>Network
. - Click the gear icon next to your connection.
- Configure IPv4/IPv6 under the
IPv4
tab (choose “Manual” for static IP).
- Open
-
Fedora/GNOME:
- Go to
Settings
>Network
>Wired/Wireless
>⚙️
>IPv4
.
- Go to
Essential Verification Commands
- Check IP address:
ip addr show
orifconfig
(install withsudo apt install net-tools
). - Test connectivity:
ping google.com
. - Verify DNS:
nslookup example.com
.
Troubleshooting Tips
🔹 “Network Unreachable”:
- Check physical cables/wireless toggle.
- Restart NetworkManager:
sudo systemctl restart NetworkManager
.
🔹 DNS Issues:
- Edit
/etc/resolv.conf
to addnameserver 8.8.8.8
(temporary fix).
🔹 Interface Not Detected:
- Verify drivers:
lspci | grep -i network
.
Final Notes
- Dynamic (DHCP) vs. Static IP: Use DHCP for automatic IP assignment (default). Use static IPs for servers.
- Tools: Prefer
ip
over deprecatedifconfig
/route
. - Distro Differences:
- Ubuntu 18.04+: Uses
netplan
(edit/etc/netplan/*.yaml
→ apply withsudo netplan apply
). - Arch Linux: See
systemd-networkd
orNetworkManager
docs.
- Ubuntu 18.04+: Uses
Master these basics, and you’ll confidently manage Linux networks! 🌐🐧