ipconfig Command in Linux

Learn via video courses
Topics Covered

Overview

The 'ipconfig' command is a commonly used tool in Windows for network administration. However, in Linux, the equivalent tool for displaying IP configuration is 'ifconfig' or the newer 'ip' command. But for the purpose of this article and to avoid confusion, we will use 'ipconfig' to refer to 'ifconfig' or 'ip'. The ipconfig command in Linux provides network configuration details of the host machine, including the IP address, subnet mask, and default gateway.

Syntax of ipconfig Command in Linux

The basic syntax of the ipconfig command in Linux is as follows:

Where:

  • option: This is optional. The command provides a host of options that allow you to manipulate the output or configure network interfaces.
  • interface: This is also optional. The name of the network interface you wish to examine or configure. If omitted, ifconfig will display information for all active interfaces.

Options in ipconfig Command in Linux

  1. -a: Displays information about all network interfaces, even those that are down.

    For example -

    Output:

    Displays information about all interfaces, not just the active ones.

  2. up: Activates an interface.

    For example -

    This command activates the eth0 interface, if it was down.

  3. down: Deactivates an interface.

    For example -

    This command deactivates the eth0 interface.

Example Usages

  • Display information of all active interfaces:

    Output:

    Explanation: The command gives information about all active network interfaces.

  • Assign an IP address to a network interface:

    Explanation: Assigns the IP address 192.168.1.10 to the eth0 interface.

Tips

  • Always run ifconfig as a root user or with sudo command for privileged tasks like changing IP addresses.

  • Use the 'man' command to access the manual and understand more about the 'ipconfig' command's capabilities.

Advanced Use Cases of ipconfig Command in Linux

  • Change the MAC address of a network interface:

    Explanation: Changes the hardware (MAC) address of the eth0 interface to 00:11:22:33:44:55.

  • Add an alias network interface:

    Explanation: Adds a secondary IP address (alias) 192.168.1.11 to the eth0 interface.

  • Display statistics for a network interface:

    Output:

    Explanation: Displays detailed statistics for the eth0 interface.

Conclusion

  • The 'ipconfig' command in Linux, represented by 'ifconfig' or 'ip', is a versatile tool for network administration.

  • It provides information about the network interfaces and allows you to configure them.

  • For advanced tasks, you can even change MAC addresses, add alias IP addresses, or get detailed interface statistics.