DEV Community

Aviral Srivastava
Aviral Srivastava

Posted on

Linux Networking Tools (ifconfig, netstat)

Linux Networking Tools: ifconfig and netstat

Introduction:

Linux provides a robust suite of command-line tools for network administration. ifconfig and netstat are two fundamental utilities used for configuring and monitoring network interfaces and connections. While ifconfig is primarily for interface configuration, netstat provides a broader overview of network activity. However, ip command has largely replaced ifconfig in modern distributions.

Prerequisites:

To use these tools, you need a Linux system with appropriate permissions (usually root privileges using sudo).

ifconfig (largely superseded by ip):

ifconfig allows manual configuration of network interfaces. It can assign IP addresses, netmasks, and configure other interface parameters.

Example (using ip):

To assign an IP address of 192.168.1.100 with a netmask of 255.255.255.0 to the interface eth0:

sudo ip addr add 192.168.1.100/24 dev eth0
Enter fullscreen mode Exit fullscreen mode

Advantages of ifconfig (and the ip replacement):

  • Direct control over interface parameters.
  • Simple syntax (though ip offers more features and a structured approach).

Disadvantages of ifconfig:

  • Limited functionality compared to ip.
  • Can lead to configuration errors if not used carefully.

netstat:

netstat displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

Example:

To view active network connections:

sudo netstat -tulnp
Enter fullscreen mode Exit fullscreen mode

Advantages of netstat:

  • Provides a comprehensive view of network activity.
  • Useful for troubleshooting network problems.

Disadvantages of netstat:

  • Output can be complex for beginners.
  • Less detailed compared to newer tools like ss.

Features: Both tools provide essential networking capabilities, but ip offers a more modern and powerful approach to interface management than ifconfig. ss is often a preferred alternative to netstat, providing more detailed and efficient output.

Conclusion:

While ifconfig and netstat were once indispensable, ip and ss are now the recommended alternatives. Understanding their basic functions, however, remains beneficial for system administrators working with Linux systems. The newer tools offer improved features, organization, and robustness.

Top comments (0)