ifconfig Command in Linux: Configure Network Interfaces

By 

Updated on

7 min read

Using the ifconfig command to configure network interfaces in Linux

ifconfig (interface configuration) is a network management tool used to configure and view the status of network interfaces in Linux. With ifconfig, you can assign IP addresses, enable or disable interfaces, change MTU values, modify MAC addresses, and more.

Warning
ifconfig is deprecated and replaced by the ip command. It may not be installed on modern Linux distributions. Where possible, use ip for new scripts and workflows.

This guide explains how to use the ifconfig command with practical examples.

How to Install ifconfig

ifconfig is part of the net-tools package, which is not installed by default on many modern distributions.

If you get an error saying ifconfig: command not found, install the package using the instructions below.

Install ifconfig on Ubuntu, Debian, and Derivatives

Terminal
sudo apt install net-tools

Install ifconfig on Fedora, RHEL, and Derivatives

Terminal
sudo dnf install net-tools

ifconfig Command Syntax

The general syntax for ifconfig is:

txt
ifconfig [INTERFACE] [OPTIONS] [ADDRESS]
  • INTERFACE — the name of the network interface (for example, eth0, ens3, or lo)
  • ADDRESS — the IP address to assign to the interface
Info
Modern Linux distributions use predictable interface names such as ens3 or enp0s3 instead of the traditional eth0. Run ifconfig -a to see the actual interface names on your system.

The configurations set with ifconfig are not persistent. After a system restart, all changes are lost. To make changes permanent, edit the distribution-specific network configuration files or use a network manager.

Only root or users with sudo privileges can modify network interfaces.

Display Network Interface Information

Run ifconfig without options to display all active network interfaces:

Terminal
ifconfig

To display all interfaces, including inactive ones, add the -a flag:

Terminal
ifconfig -a
output
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.20.10.3  netmask 255.255.255.240  broadcast 172.20.10.15
        inet6 2401:4900:1d65:40a1:4ebb:58ff:fe9c:f555  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::4ebb:58ff:fe9c:f555  prefixlen 64  scopeid 0x20<link>
        ether 4c:bb:58:9c:f5:55  txqueuelen 1000  (Ethernet)
        RX packets 84110  bytes 70667629 (70.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 59727  bytes 20886290 (20.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4198  bytes 498729 (498.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4198  bytes 498729 (498.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

To display information for a specific interface, pass its name as an argument:

Terminal
ifconfig eth0

The equivalent ip command is:

Terminal
ip addr show eth0

Assign an IP Address and Netmask to a Network Interface

To assign an IP address and netmask to an interface, use the following syntax:

txt
ifconfig INTERFACE IP_ADDRESS netmask SUBNET_MASK

For example, to assign the IP address 192.168.0.101 with netmask 255.255.0.0 to eth0:

Terminal
ifconfig eth0 192.168.0.101 netmask 255.255.0.0

You can also assign a secondary IP address using interface aliasing:

Terminal
ifconfig eth0:0 192.168.0.102 netmask 255.255.0.0

The equivalent ip command for assigning an address is:

Terminal
ip addr add 192.168.0.101/16 dev eth0

Enable and Disable a Network Interface

To disable an active network interface, pass the down flag after the interface name:

Terminal
ifconfig eth0 down

To enable an inactive interface, use the up flag:

Terminal
ifconfig eth0 up

If you are connected over SSH through the same interface, bringing it down will disconnect your session. Use caution on remote systems and make sure you have out-of-band access before applying interface state changes.

The equivalent ip commands are:

Terminal
ip link set eth0 down
ip link set eth0 up

Enable and Disable Promiscuous Mode

Promiscuous mode allows a network interface to capture and view all packets on the network segment, not just those addressed to it. It is commonly used for network analysis and packet capture with tools like tcpdump .

To enable promiscuous mode on an interface:

Terminal
ifconfig eth0 promisc

To disable promiscuous mode:

Terminal
ifconfig eth0 -promisc

The equivalent ip commands are:

Terminal
ip link set eth0 promisc on
ip link set eth0 promisc off

Change the MTU of a Network Interface

The MTU (Maximum Transmission Unit) defines the maximum size of packets transmitted on an interface. Lowering the MTU can help on networks with fragmentation issues; raising it (jumbo frames) can improve throughput on supported networks.

To change the MTU value, use the following syntax:

txt
ifconfig INTERFACE mtu MTU_VALUE

For example, to set the MTU of eth0 to 9000:

Terminal
ifconfig eth0 mtu 9000

The equivalent ip command is:

Terminal
ip link set eth0 mtu 9000

Change the MAC Address of a Network Interface

The MAC (Media Access Control) address is the hardware address that uniquely identifies a network interface on a local network.

To change the MAC address, first bring the interface down, then set the new address with the hw ether flag:

Terminal
ifconfig eth0 down
ifconfig eth0 hw ether 00:00:2d:3a:2a:28
ifconfig eth0 up

The interface must be down before changing its MAC address. The equivalent ip commands are:

Terminal
ip link set eth0 down
ip link set eth0 address 00:00:2d:3a:2a:28
ip link set eth0 up

Troubleshooting

ifconfig: command not found The net-tools package is not installed. Install it with sudo apt install net-tools on Ubuntu, Debian, and Derivatives, or sudo dnf install net-tools on Fedora, RHEL, and Derivatives.

Changes are lost after a reboot ifconfig changes are applied only to the running system and do not survive a restart. To make changes permanent, use your distribution’s network manager (NetworkManager, systemd-networkd, or Netplan) or edit the appropriate configuration files.

The interface name is not eth0 Modern Linux systems use predictable interface names such as ens3, enp0s3, or wlp2s0. Run ifconfig -a or ip link show to list the actual interface names on your system.

Cannot change the MAC address while the interface is up The interface must be brought down before changing its MAC address. Run ifconfig eth0 down first, change the address, then bring it back up with ifconfig eth0 up.

Quick Reference

ifconfig commandip equivalentDescription
ifconfigip addr showShow active interfaces
ifconfig -aip addr showShow all interfaces including inactive
ifconfig eth0ip addr show eth0Show a specific interface
ifconfig eth0 IP netmask MASKip addr add IP/PREFIX dev eth0Assign an IP address
ifconfig eth0 downip link set eth0 downDisable an interface
ifconfig eth0 upip link set eth0 upEnable an interface
ifconfig eth0 promiscip link set eth0 promisc onEnable promiscuous mode
ifconfig eth0 -promiscip link set eth0 promisc offDisable promiscuous mode
ifconfig eth0 mtu VALUEip link set eth0 mtu VALUEChange MTU
ifconfig eth0 hw ether MACip link set eth0 address MACChange MAC address

FAQ

Should I use ifconfig or ip? Use ip for new scripts and day-to-day work. ifconfig is no longer maintained and is absent from many modern distributions. The ip command provides all of the same functionality and more. See the Quick Reference table above for the ip equivalents of common ifconfig commands.

Why do my network changes disappear after a reboot? ifconfig configures the live kernel network state only. The changes are not written to any configuration file. To persist changes, use your distribution’s network configuration system — Netplan on Ubuntu, NetworkManager on Fedora, or /etc/network/interfaces on Debian.

How do I find my IP address on Linux? Run ifconfig to display all active interfaces and their assigned addresses. The inet field shows the IPv4 address and inet6 shows the IPv6 address. The modern alternative is ip addr show.

What is promiscuous mode and is it safe to enable? Promiscuous mode allows an interface to receive all packets on the network, not just those addressed to it. It is safe to enable in controlled environments for diagnostic purposes (for example, with tcpdump). On shared networks, it can capture other hosts’ traffic, so it should only be used with appropriate authorization.

Conclusion

Use ifconfig to view and configure network interfaces, assign IP addresses, toggle interface state, and modify MAC addresses and MTU values. For new systems and scripts, prefer the ip command , which replaces ifconfig and is available on most modern Linux distributions. For more details, see the ifconfig man page .

If you have any questions, feel free to leave a comment below.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page