Cybersecurity Updates & Tools

ifconfig Command in Linux: Configure Network Interfaces

The ifconfig command in Linux displays and configures network interfaces. It can assign IP addresses, bring interfaces up or down, change MTU values, enable promiscuous mode, and modify MAC addresses.

ifconfig is deprecated. It has been replaced by the ip command and is not installed by default on many modern Linux distributions. Use ip for new scripts and day-to-day work. This guide covers ifconfig for reference and for systems where it is still in use.

ifconfig is part of the net-tools package. If you see ifconfig: command not found, install it:

bashsudo apt install net-tools     # Ubuntu, Debian, and derivativessudo dnf install net-tools     # Fedora, RHEL, and derivatives

How to Use the ifconfig Command in Linux

The syntax is:

bashifconfig [INTERFACE] [OPTIONS] [ADDRESS]

Changes made with ifconfig apply to the live kernel state only. They are not written to any configuration file and will be lost after a reboot.

Run ifconfig without arguments to display all active interfaces:

bashifconfig

Add -a to include interfaces that are currently down:

bashifconfig -a

Modern Linux systems use predictable interface names such as ens3enp0s3, or wlp2s0 instead of the traditional eth0. Run ifconfig -a to see the actual names on your system before running any other commands.

To display a specific interface:

bashifconfig eth0

The output includes the IPv4 address (inet), IPv6 address (inet6), MAC address (ether), current MTU, and packet/byte counts for both received and transmitted traffic.

The ip equivalent:

baship addr show eth0

Assign an IP Address, Enable and Disable Interfaces, and Promiscuous Mode

Assign an IP address and netmask:

bashifconfig eth0 192.168.0.101 netmask 255.255.0.0

To assign a secondary IP to the same physical interface using interface aliasing:

bashifconfig eth0:0 192.168.0.102 netmask 255.255.0.0

The ip equivalent:

baship addr add 192.168.0.101/16 dev eth0

Bring an interface down or up:

bashifconfig eth0 downifconfig eth0 up

If you are connected over SSH through the same interface, running ifconfig eth0 down will immediately cut your session. Make sure you have an alternative path to the system before bringing an interface down on a remote machine.

The ip equivalents:

baship link set eth0 downip link set eth0 up

Promiscuous mode allows an interface to receive all packets on the network segment, not just those addressed to it. It is used for network analysis and packet capture with tools like tcpdump. Only enable it with proper authorization:

bashifconfig eth0 promisc      # enableifconfig eth0 -promisc     # disable

Change MTU, Modify MAC Address, and Make Changes Permanent

Change the MTU. The MTU (Maximum Transmission Unit) sets the maximum packet size the interface will transmit. The standard Ethernet MTU is 1500 bytes. Lowering it can help on networks with fragmentation issues. Setting it to 9000 enables jumbo frames, which improves throughput – but every device on the path must also support the larger size:

bashifconfig eth0 mtu 9000

The ip equivalent:

baship link set eth0 mtu 9000

Change the MAC address. The kernel requires the interface to be in the DOWN state before its hardware address can be changed:

bashifconfig eth0 downifconfig eth0 hw ether 00:00:2d:3a:2a:28ifconfig eth0 up

The ip equivalents:

baship link set eth0 downip link set eth0 address 00:00:2d:3a:2a:28ip link set eth0 up

Make changes permanent. ifconfig only configures the running system. To persist changes across reboots, use your distribution’s network stack: Netplan on Ubuntu, NetworkManager on Fedora, or /etc/network/interfaces on Debian.

For new systems and scripts, use ip instead of ifconfig. If you are maintaining older infrastructure where ip is not available, the patterns above cover the most common tasks. Leave a comment below if you run into any issues.