In this article, you will learn how to list, configure, enable, disable, and troubleshoot network interfaces in Linux using 15 useful ifconfig commands with practical examples.

ifconfig (Interface Configuration is a utility for system/network administration in Unix/Linux operating systems used to configure, manage, and query network interface parameters via the command-line interface or in system configuration scripts.

The ifconfig command is used for displaying current network configuration information, setting up an IP address, netmask, or broadcast address to a network interface, creating an alias for a network interface, setting the hardware address, and enabling or disabling network interfaces.

Update: The ifconfig command is deprecated and has been replaced by the ip command in most modern Linux distributions. It is part of the net-tools package, which may not be installed by default on newer systems.

To install it, run:

sudo apt install net-tools #Debian/Ubuntu
sudo dnf install net-tools #RHEL/Fedora

1. How to List All Active Network Interfaces in Linux

The ifconfig command with no arguments will display all active network interface configuration details, including their assigned IP addresses, netmasks, and other relevant information.

ifconfig

Sample Output:

ens3      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2341604 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2217673 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293460932 (279.8 MiB)  TX bytes:1042006549 (993.7 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:5019066 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5019066 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2174522634 (2.0 GiB)  TX bytes:2174522634 (2.0 GiB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Note: Modern Linux distributions use predictable network interface names such as ens3, enp3s0, or eno1 instead of the traditional eth0 naming convention.

2. How to Display Information on All Network Interfaces

The following ifconfig command with the -a argument will display information on all active or inactive network interfaces on the server. It displays the results for eth0, lo, sit0, and tun0.

ifconfig -a

Sampple Output:

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293839516 (280.2 MiB)  TX bytes:1043722206 (995.3 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5022927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2175739488 (2.0 GiB)  TX bytes:2175739488 (2.0 GiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

3. How to View Network Settings of a Specific Interface

Using an interface name (e.g., ens3) as an argument with the ifconfig command will display configuration details for that specific network interface only.

ifconfig ens3

Sampple Output:

ens3      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2345583 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2221421 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293912265 (280.2 MiB)  TX bytes:1044100408 (995.7 MiB)

4. How to Enable a Network Interface

The up flag with an interface name activates a network interface if it is in an inactive state, allowing it to send and receive data.

For example, ifconfig ens3 up will activate the ens3 interface.

ifconfig ens3 up

Note: The ifup command was traditionally used as an alternative to bring interfaces up, but it is no longer available by default on many modern distributions such as RHEL 8+, Ubuntu 18.04+, and Fedora. The recommended modern approach is to use ip link set ens3 up or manage interfaces through NetworkManager using the nmcli command.

5. How to Disable a Network Interface

The down flag with an interface name deactivates the specified network interface,f or example, the ifconfig ens3 down command deactivates the ens3 interface.

ifconfig ens3 down

Note: Similar to ifup, the ifdown command is not available by default on most modern Linux distributions. Use ip link set ens3 down or nmcli as the modern alternative.

6. How to Assign an IP Address to a Network Interface

To assign an IP address to a specific interface, use the ifconfig command with the interface name and the IP address you want to set.

For example, the following command sets the IP address on the ens3 interface.

ifconfig ens3 172.16.25.125

Note: IP addresses assigned this way are not persistent and will be lost after a system reboot. To make changes permanent, configure the network through NetworkManager or by editing the appropriate network configuration files for your distribution.

7. How to Assign a Netmask to a Network Interface

Using the ifconfig command with the netmask argument and an interface name allows you to define a subnet mask for the given interface.

For example, the following command sets the netmask on the ens3 interface.

ifconfig ens3 netmask 255.255.255.224

8. How to Assign a Broadcast Address to a Network Interface

Using the broadcast argument with an interface name will set the broadcast address for the given interface. For example, the following command sets the broadcast address on the ens3 interface.

ifconfig ens3 broadcast 172.16.25.63

9. How to Assign an IP Address, Netmask, and Broadcast Address Together

To assign an IP address, netmask, and broadcast address all at once, use the ifconfig command with all three arguments as shown below.

ifconfig ens3 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63

10. How to Change the MTU for a Network Interface

The mtu argument sets the Maximum Transmission Unit for an interface. The MTU defines the largest size of packet (in bytes/octets) that the interface will transmit in a single transaction.

Adjusting the MTU is useful in specific network environments, such as when using VPNs or jumbo frames.

For example, the following command sets the MTU to 1000 on the ens3 interface.

ifconfig ens3 mtu 1000

Note: Not all network interfaces support MTU changes. The default MTU for Ethernet interfaces is 1500 bytes. Setting it too low can degrade performance, so change it only when required.

11. How to Enable Promiscuous Mode on a Network Interface

In normal mode, when a network card receives a packet, it checks whether the packet is addressed to itself. If not, it drops the packet. In promiscuous mode, the network interface accepts all packets flowing through the network, regardless of their destination address.

Network monitoring and packet analysis tools such as tcpdump and Wireshark rely on promiscuous mode to capture traffic.

To enable promiscuous mode on an interface, use the following command.

ifconfig ens3 promisc

12. How to Disable Promiscuous Mode on a Network Interface

To disable promiscuous mode and return the network interface to normal operation, use the -promisc switch as shown below.

ifconfig ens3 -promisc

13. How to Add an Alias to a Network Interface

The ifconfig utility allows you to configure additional IP addresses on the same physical interface using the alias feature, which is useful when you need a single interface to respond to multiple IP addresses.

To add an alias for the ens3 interface, use the following command, but do note that the alias IP address must be within the same subnet as the primary IP address.

For example, if your primary IP is 172.16.25.125, a valid alias would be 172.16.25.127.

ifconfig ens3:0 172.16.25.127

Next, verify the newly created alias interface by running the following command.

ifconfig ens3:0

Sample Output:

ens3:0    Link encap:Ethernet  HWaddr 00:01:6C:99:14:68
          inet addr:172.16.25.127  Bcast:172.16.25.63  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

Note: Interface aliases are not persistent across reboots. For permanent multiple IP addresses on a single interface, configure them through NetworkManager or the distribution-specific network configuration files.

14. How to Remove an Alias from a Network Interface

If you no longer require an alias network interface or configured it incorrectly, you can remove it using the following command.

ifconfig ens3:0 down

15. How to Change the MAC Address of a Network Interface

To change the MAC (Media Access Control) address of a network interface, use the ifconfig command with the hw ether argument followed by the new MAC address. Note that the interface must be brought down before changing its MAC address on some systems.

ifconfig ens3 down
ifconfig ens3 hw ether AA:BB:CC:DD:EE:FF
ifconfig ens3 up

Note: MAC address changes made this way are temporary and will revert after a reboot. For permanent changes, use ip link or configure it through NetworkManager.

These are the most useful ifconfig commands for configuring network interfaces in Linux. For more information and usage options, refer to the man page by running man ifconfig at the terminal.

Since ifconfig is deprecated on most modern Linux distributions, it is worth familiarizing yourself with the ip command as the recommended replacement for managing network interfaces going forward.

Other Networking Utilities

  • nmcli – a command-line client that is used to control NetworkManager and report network information.
  • Tcmpdump – is a command-line packet capture and analyzer tool for monitoring network traffic.
  • Netstat – is an open-source command-line network monitoring tool that monitors incoming and outgoing network packet traffic.
  • ss (socket statistics) – a tool that prints network socket-related information on a Linux system.
  • Wireshark – is an open-source network protocol analyzer that is used to troubleshoot network-related issues.
  • Munin – is a web-based network and system monitoring application that is used to display results in graphs using rrdtool.
  • Cacti – is a complete web-based monitoring and graphing application for network monitoring.

To get more information and options for any of the above tools, see the man pages by entering “man toolname” at the command prompt. For example, to get the information for the “netstat” tool, use the command “man netstat“.

Share.
Leave A Reply