Network interfaces are the connection points between your Linux system and networks. They handle communication between your computer and other devices, whether through Ethernet, Wi-Fi, or virtual connections. Understanding network interfaces is crucial for system administration, troubleshooting connectivity issues, and configuring network services.
Key Concepts
- Physical Interface: Hardware network adapters (eth0, wlan0)
- Virtual Interface: Software-created interfaces (lo, docker0)
- Interface State: Up (active) or down (inactive)
- IP Address: Unique network identifier assigned to interface
- MAC Address: Hardware identifier for physical interfaces
- Netmask: Defines network and host portions of IP address
Command Syntax
ip [options] object command
- Modern tool for network interface management
- Replaces older ifconfig command
- More powerful and feature-rich
Common Options
ip link - Manage network interfaces
ip addr - Manage IP addresses
ip route - Manage routing table
-s - Show statistics
-4 - IPv4 only
-6 - IPv6 only
Practical Examples
Example 1: View all interfaces
|
|
Shows interface names, states, and properties
Example 2: View IP addresses
|
|
Displays IP addresses assigned to interfaces
Example 3: Bring interface up/down
|
|
Controls interface activation state
Example 4: Assign IP address
|
|
Adds or removes IP address from interface
Example 5: View interface statistics
|
|
Shows traffic statistics for troubleshooting
Use Cases
- Network Configuration: Setting up new connections
- Troubleshooting: Diagnosing connectivity issues
- Monitoring: Checking interface status and traffic
- Virtualization: Managing virtual network interfaces
- Security: Controlling network access points
Related Commands
ifconfig - Legacy interface configuration tool
netstat - Display network connections and statistics
ss - Modern replacement for netstat
nmcli - NetworkManager command-line interface
ethtool - Query/control network driver settings
Tips & Troubleshooting
Common Issues
- Interface down: Check with
ip link show, bring up withip link set <interface> up - No IP address: Assign manually or check DHCP with
dhclient <interface> - Wrong IP: Remove old IP before adding new one
Performance Tips
- Use
ip -s linkto monitor packet drops/errors - Check MTU settings for performance issues
- Monitor interface utilization with
iftopornload
Security Notes
- Disable unused interfaces to reduce attack surface
- Monitor for unexpected interfaces (security breach indicator)
- Use firewall rules to control interface access
- Regular auditing of interface configurations recommended
Legacy vs Modern Commands
|
|
Always prefer ip command over ifconfig in modern systems