1. Network Configuration Files
Linux uses various files to configure network settings:
- /etc/hosts: Maps hostnames to IP addresses
- /etc/resolv.conf: DNS resolver configuration
- /etc/network/interfaces (Debian/Ubuntu) or /etc/sysconfig/network-scripts/ (Red Hat/CentOS): Network interface configuration
2. Network Interface Management
Common commands for managing network interfaces:
# Display network interfaces
ip link show
# Bring an interface up or down
sudo ip link set eth0 up
sudo ip link set eth0 down
# Assign an IP address
sudo ip addr add 192.168.1.10/24 dev eth0
# Remove an IP address
sudo ip addr del 192.168.1.10/24 dev eth0
3. Network Troubleshooting Commands
- ping: Test connectivity to a host
- traceroute: Trace the route packets take to a host
- netstat or ss: Display network connections
- nslookup or dig: Query DNS servers
- tcpdump: Capture and analyze network traffic
# Examples
ping google.com
traceroute google.com
ss -tuln
dig google.com
sudo tcpdump -i eth0
4. Firewall Configuration
Many Linux distributions use iptables or its frontend, ufw (Uncomplicated Firewall):
# Check firewall status
sudo ufw status
# Enable firewall
sudo ufw enable
# Allow incoming traffic on a specific port
sudo ufw allow 22/tcp
# Deny incoming traffic on a specific port
sudo ufw deny 23/tcp
5. Network Services
Common network services in Linux:
- ssh: Secure Shell for remote access
- apache2 or nginx: Web servers
- bind9: DNS server
- samba: File sharing for Windows networks
# Start, stop, or restart a service (using systemd)
sudo systemctl start ssh
sudo systemctl stop apache2
sudo systemctl restart nginx
6. Network File Systems
Linux supports various network file systems:
- NFS (Network File System): Unix/Linux file sharing
- CIFS/SMB: Windows file sharing (via Samba)
# Mount an NFS share
sudo mount -t nfs server:/share /mnt/nfs
# Mount a CIFS share
sudo mount -t cifs //server/share /mnt/cifs -o username=user,password=pass
7. Network Monitoring
Tools for monitoring network performance and usage:
- iftop: Display bandwidth usage on an interface
- nethogs: Show per-process network usage
- iotop: Monitor I/O usage of processes
- nmon: Monitor various system resources including network
Note:
Always be cautious when modifying network settings, especially on remote servers. Incorrect configuration can lead to loss of connectivity.
8. IPv6 Configuration
As IPv6 becomes more prevalent, it's important to understand its configuration:
# Enable IPv6 on an interface
sudo sysctl -w net.ipv6.conf.eth0.disable_ipv6=0
# Assign an IPv6 address
sudo ip -6 addr add 2001:db8::1/64 dev eth0
# Display IPv6 routing table
ip -6 route show