Home > Network Management > ifconfig

ifconfig Command Guide: Checking and Configuring Network Interface Information (Legacy)

`ifconfig` command is a utility used to check and configure network interface information in Linux and Unix-like operating systems. It can display IP addresses, MAC addresses, network statistics, and more. **However, the more powerful and flexible `ip` command has replaced `ifconfig` in modern Linux systems, so it is recommended to use the `ip` command.** This guide will help you learn the basic usage of `ifconfig` and understand why you should transition to `ip`.

Overview of ifconfig

`ifconfig` stands for 'interface configurator' and has long been used to manage network interfaces connected to the system. However, it is being replaced by the `ip` command from the `iproute2` toolset due to lack of IPv6 support, difficulty in complex scripting, and more.

Main Functions of ifconfig

`ifconfig` command is primarily used for the following purposes:

Key Use Cases (Past and Some Systems)

  • Check Network Interface Status: Displays the IP address, subnet mask, MAC address, etc., of each interface.
  • Check Network Statistics: Shows the number of packets sent and received, errors, collisions, etc., per interface.
  • Activate/Deactivate Interface: Used to turn a specific network interface on or off.
  • Set IP Address: Assigns or changes the IP address for an interface.

`ifconfig` vs `ip`

`ifconfig` is still used in some older systems or specific environments, but new feature development has stopped, and `ip` has completely replaced its role.

  • ifconfig: Legacy tool, lacks IPv6 support, limited functionality.
  • ip: Modern and powerful, fully supports IPv6, provides various advanced features like routing and tunneling.

Installing ifconfig (Optional)

Some recent Linux distributions (e.g., from Ubuntu 18.04+) may not have `ifconfig` installed by default. If necessary, you can install the `net-tools` package to use it.

Install `ifconfig` (Debian/Ubuntu)

sudo apt update
sudo apt install net-tools

Command to install the `net-tools` package containing `ifconfig` on Debian or Ubuntu-based systems.

Key ifconfig Command Options

`ifconfig` command allows you to query network interfaces and perform basic configurations with a simple syntax. (Usually requires administrative privileges)

1. Information Query

2. Interface Configuration (Administrative Privileges Required)

Generated command:

Try combining the commands.

Description:

`ifconfig` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn how to check information about network interfaces and perform basic configurations through various examples of the `ifconfig` command.

Check Information of All Active Network Interfaces

ifconfig

Displays the IP addresses, MAC addresses, statistics, etc., of all active network interfaces (e.g., `eth0`, `lo`) on the current system.

Check Specific Interface (eth0) Information

ifconfig eth0

Displays detailed information for the network interface named `eth0`.

Activate Specific Interface

sudo ifconfig eth0 up

Activates (UP) the `eth0` interface. This command requires administrative privileges.

Set IP Address and Netmask for Interface

sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0

Sets the IP address `192.168.1.10` and netmask `255.255.255.0` for the `eth0` interface. (This is a temporary setting and may disappear upon reboot.)

Check Including All Inactive Interfaces

ifconfig -a

Displays information about all network interfaces, whether active or inactive. This can be useful for diagnosing problems.

Check Status of Loopback Interface (lo)

ifconfig lo

Checks the status of the `lo` (loopback) interface, which refers to the local system itself. This is used for local testing without a network connection.


Same category commands