Linux Network Configuration and Monitoring Commands
Overview
Linux provides a variety of commands for configuring and monitoring network interfaces and connections. These commands are essential for managing network settings, diagnosing network issues, and ensuring proper connectivity. This document covers basic and commonly used network configuration and monitoring commands.
Network Configuration
ip
A powerful tool for configuring network interfaces, routing, and tunnels.
Display Network Interfaces
Example
Display Routing Table
Example
Add an IP Address
Example
sudo ip addr add 192.168.1.100/24 dev eth0
# Adds the IP address 192.168.1.100 with subnet 24 to the interface 'eth0'
Delete an IP Address
Example
sudo ip addr del 192.168.1.100/24 dev eth0
# Removes the IP address 192.168.1.100 from the interface 'eth0'
ifconfig
Displays and configures network interfaces. Note: ifconfig
is deprecated in favor of ip
.
Example
nmcli
Command-line interface for NetworkManager, used to manage network connections.
List Network Connections
Example
Connect to a Network
Example
Disconnect from a Network
Example
Network Monitoring
ping
Sends ICMP ECHO_REQUEST packets to a network host to check connectivity.
Example
traceroute
Displays the route packets take to a network host.
Example
netstat
Displays network connections, routing tables, and interface statistics. Note: netstat
is deprecated in favor of ss
.
Display All Connections
Example
ss
Displays detailed information about network sockets.
Display All Connections
Example
tcpdump
Captures and analyzes network packets.
Example
iftop
Displays bandwidth usage on network interfaces.
Example
nmap
Network scanning tool used to discover hosts and services on a network.
Example
Summary
Linux provides a comprehensive set of commands for configuring and monitoring network interfaces and connections. These commands are essential for managing network settings, diagnosing issues, and ensuring network connectivity. For more detailed information on each command, refer to the Linux manual pages.