Network Interfaces

Understanding and managing network interfaces including physical, virtual, and configuration

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

1
2
3
4
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
3: wlan0: <BROADCAST,MULTICAST> mtu 1500

Shows interface names, states, and properties

Example 2: View IP addresses

1
2
3
4
5
ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP>
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 192.168.1.100/24 brd 192.168.1.255

Displays IP addresses assigned to interfaces

Example 3: Bring interface up/down

1
2
sudo ip link set eth0 down
sudo ip link set eth0 up

Controls interface activation state

Example 4: Assign IP address

1
2
sudo ip addr add 192.168.1.50/24 dev eth0
sudo ip addr del 192.168.1.50/24 dev eth0

Adds or removes IP address from interface

Example 5: View interface statistics

1
2
3
4
5
6
ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    RX: bytes packets errors dropped
        1048576  1024    0      0
    TX: bytes packets errors dropped
        524288   512     0      0

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

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 with ip 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 link to monitor packet drops/errors
  • Check MTU settings for performance issues
  • Monitor interface utilization with iftop or nload

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

1
2
3
4
5
# Old way (deprecated)
ifconfig eth0 192.168.1.100/24

# New way (recommended)
ip addr add 192.168.1.100/24 dev eth0

Always prefer ip command over ifconfig in modern systems