Network Management
Networking management in linux is a crucial to make a robust linux system. well at least we know some essential networking tasks, like configuring interfaces, managing IP addresses, setting up routing, and using firewalls.
Checking Network Interfaces​
To check the available network interfaces, use:
ip link show
Or using the deprecated ifconfig
(requires installation on some distributions)
ifconfig -a
To display detailed interface information:
ip addr show
Configuring Network Interfaces​
To bring up or down a network interface:
sudo ip link set eth0 up # Enable interface
sudo ip link set eth0 down # Disable interface
For ifconfig
users (it's deprecated bro, leave it):
sudo ifconfig eth0 up
sudo ifconfig eth0 down
Managing IP Addresses​
To assign an static IP address to an interface temporarily:
sudo ip addr add 192.168.1.10/24 dev eth0
To make changes persistent, edit the /etc/network/interfaces
configurations (Debian based).
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 8.8.4.4
or edit /etc/sysconfig/network-scripts/ifcfg-eth0
if u use RHEL-based systems.
To remove an IP address:
sudo ip addr del 192.168.1.10/24 dev eth0
To check current IP addresses:
ip a
Routing and Default Gateway​
To check routing information:
ip route show
To add a default gateway:
sudo ip route add default via 192.168.1.1
To remove a default gateway:
sudo ip route del default
Managing Network Services​
To check the status of the networking service:
sudo systemctl status networking
To restart networking:
sudo systemctl restart networking
To enable network services at boot:
sudo systemctl enable networking
For NetworkManager
users:
nmcli connection show
nmcli device status
Troubleshooting Network Issues​
To check connectivity:
ping 8.8.8.8
To check DNS resolution:
nslookup google.com
To trace network routes:
traceroute google.com
To analyze network traffic:
tcpdump -i eth0
To check open ports:
sudo netstat -tulnp
Or using ss
(modern alternative):
ss -tulnp