ifconfig Command in Linux: Configure Network Interfaces

By 

•

Updated on

•

11 min read

Using the ifconfig command to configure network interfaces in Linux

When a server comes back from a reboot with no network, the fastest way to see what the interfaces are doing is to ask them directly. ifconfig (interface configuration) is the classic tool for that job, 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.

To calculate the network and usable host range for a netmask, use the interactive subnet calculator .

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

Once the package is in place, confirm that the binary responds:

Terminal
/usr/sbin/ifconfig -V

The command prints the net-tools release string and exits. Using the full path also works on Debian systems where /usr/sbin is not included in a regular user’s PATH.

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

The options that change how ifconfig reports are:

  • -a - display all interfaces, including the ones that are down
  • -s - display a short list, in the same format as netstat -i
  • -v - print more detail for some error conditions
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 2001:db8:10::3  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

Each block starts with the interface name, followed by the fields that describe its current state:

  • flags - The interface flags, printed as a number and a readable list. UP means the interface is administratively enabled. RUNNING means its operational state is up or unknown, but it does not guarantee a usable connection. BROADCAST and MULTICAST mean the interface supports those traffic types. For Ethernet carrier state, check for LOWER_UP with ip link show.
  • mtu - The largest packet the interface will transmit, in bytes.
  • inet, netmask, broadcast - The IPv4 address, its subnet mask, and the broadcast address of the subnet.
  • inet6, prefixlen, scopeid - The IPv6 addresses. A global scope address is not restricted to the local link, but routing and firewall rules still determine whether it is reachable. A link scope address starting with fe80:: is valid only on the local segment.
  • ether - The MAC address of the interface, with the hardware type in parentheses.
  • txqueuelen - The length of the transmit queue for the device.
  • RX and TX - Packet counts and byte totals received and transmitted, each followed by its error counters.

The error counters are the part worth reading closely. RX errors counts bad packets received by the interface, while TX errors counts transmission problems. RX dropped counts received packets that were not processed, often because of resource limits, unsupported protocols, or filtering. TX dropped counts packets discarded before transmission. overruns reports FIFO or buffer overflow events, and collisions counts Ethernet collisions during transmission.

A nonzero or rising counter does not identify one cause by itself. Congestion, resource pressure, filtering, driver behavior, and physical link problems can all affect these values. Compare repeated samples and check the detailed counters with ip -s link before drawing a conclusion.

One caveat applies to interface aliases such as eth0:0. Since kernel 2.2 there are no separate statistics for aliases, so the counters printed for an alias are the counters of the parent device.

For a condensed view of the same statistics, use the -s flag:

Terminal
ifconfig -s
output
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0             1500    84110      0      0 0         59727      0      0      0 BMRU
lo              65536     4198      0      0 0          4198      0      0      0 LRU

The Flg column packs the interface flags into single letters. B is broadcast, M is multicast, R is running, U is up, L is loopback, and P is promiscuous, so the BMRU on eth0 above is the short form of the flags line in the full output.

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

When you need the addresses and nothing else, filter the output:

Terminal
ifconfig eth0 | grep inet
output
        inet 172.20.10.3  netmask 255.255.255.240  broadcast 172.20.10.15
        inet6 2001:db8:10::3  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::4ebb:58ff:fe9c:f555  prefixlen 64  scopeid 0x20<link>

Because inet6 contains inet, both families are matched. Use grep -w inet to keep the IPv4 line alone. Our guide on finding your IP address in Linux covers the other ways to get the same answer.

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

Assign an IPv6 Address to a Network Interface

IPv4 addresses are passed straight to ifconfig, but IPv6 addresses go through the inet6 address family and the add keyword:

txt
ifconfig INTERFACE inet6 add ADDRESS/PREFIXLEN

For example, to add 2001:db8::1 with a 64-bit prefix to eth0:

Terminal
ifconfig eth0 inet6 add 2001:db8::1/64

Run ifconfig eth0 afterwards and the new address appears as an extra inet6 line with global scope. To take it away again, swap add for del:

Terminal
ifconfig eth0 inet6 del 2001:db8::1/64

The equivalent ip commands are:

Terminal
ip -6 addr add 2001:db8::1/64 dev eth0
ip -6 addr del 2001:db8::1/64 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.

ifconfig: command not found after installing net-tools
Debian installs the binary as /usr/sbin/ifconfig, but /usr/sbin may not be part of a regular user’s PATH. Call it by its full path with /usr/sbin/ifconfig.

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 -sip -s linkShow a short list with interface counters
ifconfig eth0ip addr show eth0Show a specific interface
ifconfig eth0 IP netmask MASKip addr add IP/PREFIX dev eth0Assign an IPv4 address
ifconfig eth0 inet6 add IP/PREFIXip -6 addr add IP/PREFIX dev eth0Assign an IPv6 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 a deprecated legacy tool 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, or the ip command cheatsheet for a printable version.

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 .

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 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page