Home A-Z Commands 40 Most Useful Linux ifconfig Commands for Network Admins

40 Most Useful Linux ifconfig Commands for Network Admins

Rigorous networking is one of the best selling points of most Linux and BSD systems. A plethora of awe-inspiring networking tools is available in Linux for making your life hassle-free. The ifconfig command in Linux is one such utility that makes network management much easier for admins. Ifconfig stands for ‘interface configuration’ and is a handy tool for controlling and managing networking interfaces in Unix-like operating systems. It is available in most Linux distributions by default. Today, we’ll discuss 40 most useful Linux ifconfig commands to help you understand this tool in detail.

Linux ifconfig Commands with Examples


We’ve tried to outline various ifconfig commands with necessary examples. You can use many of these commands to assign, add, delete, control, and query your Linux network interface parameters. You should definitely try them out for gaining first-hand experience. So, open up a terminal and start learning ifconfig in detail.

Linux ifconfig basics

1. View Active Network Interfaces

Simply running the ifconfig command without any arguments will list out the active network interfaces. You don’t need sudo privileges for this task.

$ ifconfig

It lists out three different interfaces in my system. Yours may vary based on your network and choice of Linux distribution. Moreover, the interface names can also be different. Generally, the first one is the ethernet interface, lo is the localhost interface, and the wlan0/wlp2s0 is the wireless network interface.

2. View All Network Interfaces

You can add the -a flag to ifconfig for listing out every single network interface in your system.

$ ifconfig -a

In my system, both ifconfig and ifconfig -a displays the same output since these are the only interfaces in this machine. However, yours may vary based on how the system configured your network interfaces.

3. View Short List of Network Interfaces

By default, the ifconfig utility provides too many technical details about your network interfaces. You can tell ifconfig to print out only a small detail instead by using the -s flag. Check out the below command.

$ ifconfig -s

This command is handy in a number of situations where you’re only interested in the summarization of your interfaces.

4. View Detailed List of Network Interfaces

Contrary to the -s flag, the -v flag provides much more detail about your network interfaces. You should use this flag when you’re troubleshooting your networks or looking for transmission details.

$ ifconfig -v

The -v stands for verbose and provide some extra information than the standard ifconfig command with no arguments specified.

5. Monitor Specific Network Interfaces

You can use the ifconfig command to monitor a particular network interface only. Simply enter the name of the interface, followed by ifconfig.

$ ifconfig <INTERFACE>
$ ifconfig wlp2s0

My wireless interface is named wlp2s0. So I’ve used this command. Replace the interface name with your desired interface name. It will provide a lot of information about the interface, such as the gateway, sub-network, MAC, IP, interface state, etc.

6. Enable Specific Network Interface

You can use the ifconfig command in Linux for enabling or disabling specific network interfaces. The below command shows you how to enable an ethernet interface named eth0 using ifconfig.

$ ifconfig eth0 up

This command will activate the eth0 interface for ethernet communication in your system. Once again, if you fail to enable ethernet in this way, make sure your interface is actually called eth0. The below command is equivalent to the above command.

$ ifup eth0

This command will work the same way with other network interfaces.

7. Disable Specific Network Interface

The below command does the exact opposite of the previous one. You can use it to de-activate any specific network interface pretty quickly. Simply use down instead of up after the desired interface name.

$ ifconfig eth0 down

The ability to enable and disable specific network interfaces will come in handy when you’re troubleshooting large networks. The alternative to this command is shown below.

$ ifdown eth0

You can also do this by using the ip command nowadays. But ifconfig is widely used by system admins for this purpose.

8. View all Assigned IP Addresses

You can view all IP addresses associated with your network interface pretty quickly using the ifconfig command. We’re demonstrating a quick example to help you understand this clearly.

$ ifconfig | grep inet

This command will provide an output containing all the lines that contain the IP addresses. We’re utilizing the grep command to filter out these IPs. They are known as inet in ifconfig. When you run this Linux ifconfig command, you will get both IPv4 and IPv6 addresses.

9. View only IPv4 Addresses

The above command provides both class 4 and 6 IP addresses. You can use the following command to list only the IPv4 addresses.

$ ifconfig | grep -w inet

If you run this command, you will see there’re no IPv6 addresses in the output. It could be useful if you’re scripting the interface configuration of your network.

10. Assign IP Addresses to Interfaces

The Linux ifconfig utility can be used for specifying the IP address of a particular network interface. Simply provide the IP you want to specify, followed by the name of your interface. A simple example is demonstrated below.

$ sudo ifconfig eth0 198.12.14.123

You need sudo privileges to run this command as you’re explicitly changing a network interface parameter. Run the ifconfig command one more time to view the changes in the IP address field. Once again, this field is known as inet in ifconfig.

11. View Network Interface Masks

The below command will show you how to list the netmasks of your network interfaces. You can use this command to filter the default ifconfig output for specific information about your network masks.

$ ifconfig | grep netmask

Here, the grep command is cutting the lines containing the word netmask.

12. Assign a Specific Netmask to an Interface

Netmasks are used universally for dividing up a network into multiple subnetworks. You can assign customized network masks using the ifconfig command pretty quickly. Check out the below example for an in-depth understanding of this concept.

$ sudo ifconfig eth0 netmask 255.255.255.250

This command will assign the netmask 255.255.255.250 to your IP address. Don’t forget to use sudo, or you can also run this command directly as root.

13. View Broadcast Address of Interfaces

Broadcast addresses are used for sending messages to all hosts in a network. You can use the following command to find out the broadcast addresses of your network interfaces very quickly.

$ ifconfig | grep broadcast

This command will list all the lines where the broadcast address is present.

14. Assign a Broadcast Address to a Network Interface

By default, your system will assign a broadcast address to your interfaces. However, you can assign customized broadcast addresses yourself using the ifconfig command in Linux.

$ sudo eth0 broadcast 192.162.125.200

So, all you need to do is pass the broadcast option alongside the broadcast IP after the name of the desired interface. You can do the same with other interfaces.

15. Assign Mulitple Network Parameters at Once

Often you will want to assign multiple network interface parameters for your network. You don’t need to assign these parameters one by one as the Linux ifconfig utility allows admins to do this all at once. The below demonstration will make this clear.

$ sudo ifconfig eth0 198.12.14.123 netmask 255.255.255.200 broadcast 192.162.125.200

So all you need to do here is pass the arguments one after another at the same line. This command will have the same effect on eth0 as the above three ifconfig commands.

16. View the Current MTU of Interfaces

MTU stands for ‘maximum transmission unit’ and specifies the size limit of packets that are transmitted via a particular interface. The below ifconfig command in Linux can be used for displaying the currently set MTUs of your interfaces.

$ ifconfig | grep mtu

You can also change these values without any hassle. The next command will show you how to do this.

17. Assign Custom MTU to an Interface

Although not all network interfaces support MTU, you can change their default value for those that support it. Check out the below command to learn how you can tackle this.

$ sudo ifconfig eth0 mtu 1000

The above command will change the MTU of eth0 to 1000. Rerun the ifconfig command to check whether the MTU has been updated or not.

18. Enable Promiscuous Mode

Usually, your network interfaces will only pass the packets they are programmed to pass to your CPU. In promiscuous mode, your network interfaces will catch every single packet it receives on an interface. The below ifconfig command can be used to enable promiscuous mode for a network interface.

$ sudo ifconfig eth0 promisc

The above command will enable promiscuous mode for the ethernet interface eth0. Now eth0 will redirect every received packet to the processing unit directly.

19. Disable Promiscuous Mode

You can also disable this promiscuous mode anytime you want. All you need to do is add a preceding – sign to the promisc argument, as shown below.

$ sudo ifconfig eth0 -promisc

Run the ifconfig command one more time to check whether the operation ended successfully or not.

20. Create an Alias for a Network Interface

You can configure additional network interfaces using the alias feature of the Linux ifconfig utility. However, the IP address of your network interface alias must be the same as the original interface. Take a look at the below example to understand how this works.

$ sudo ifconfig eth0:0 198.12.14.123

This command creates an alias of the eth0 interface called eth0:1. You can check out this new interface by using the below command.

$ ifconfig eth0:0

21. Remove a Network Interface Alias

You can remove a particular alias for a network interface pretty quickly by using the down argument. The below example demonstrates how to remove the alias eth0:1 we created in the previous example.

$ ifconfig eth0:0 down

This command will remove the alias we created earlier. Run the ifconfig command one more time to check this.

22. View MAC Address of Network Interfaces

The MAC address is a unique identifier assigned to each network interface by your Linux machine. You can use the below command to print out the MAC addresses of your network interfaces pretty easily.

$ ifconfig | grep ether

In ifconfig terms, ether denotes the MAC of an interface. So, we’re using this to filter out the rest of the outputs.

23. Change the MAC Address of an Interface

You can change the MAC address of your interfaces manually using the ifconfig command. A basic example is demonstrated below. First, disable the interface using ifconfig down.

$ sudo ifconfig eth0 down

Now, we can change the MAC address of this interface.

$ sudo ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

The MAC is known as ether in ifconfig terms. Here, we’re using the hw ether arguments to change this value to a new one. Enable the interface again using ifconfig up.

$ sudo ifconfig eth0 up

24. Enable the ARP Protocol for an Interface

The ARP protocol is a communication protocol used for discovering information such as the MAC address of an interface. To enable this protocol for a given interface, use the next command.

$ sudo eth0 arp

This command will enable ARP for the interface eth0. You can use the same command for enabling ARP for your ethernet interface. Simply replace eth0 with the name of your interface.

25. Disable the ARP Protocol for an Interface

You can use the below command to disable the ARP protocol for an interface. Notice the similarity this command has with the command you used for disabling the promiscuous mode.

$ sudo eth0 -arp

So, merely appending before the arp argument will disable this protocol for the said interface.

26. Enable All-Multicast Mode For an Interface

In multicast communication, all network transmissions are addressed to a group of destinations at the same time. When the all-multicast option is enabled for a network interface, it will receive all the multicast packets directly.

$ sudo ifconfig eth0 allmulti

This command will enable the all-multicast feature for the ethernet interface eth0.

27. Disable All-Multicast Mode For an Interface

Disabling the all-multicast feature is suitable for home users due to a number of reasons. You can do this using ifconfig pretty quickly. The below command shows how to do this.

$ sudo ifconfig eth0 -allmulti

So, simply adding a preceding before the allmulti argument will disable this feature for a particular network interface.

28. Add an IPv6 Address to a Network Interface

The Linux ifconfig utility allows users to add or remove IPv6 addresses to specific network interfaces. For this, you will need to use the add argument, followed by the addr/prefixlen. The next command shows how we can assign a new IPv6 address to the wireless interface wlp2s0.

$ sudo ifconfig eth0 add 2001:0db8:0:f101::1/64

Here, we’re assigning the IPv6 address 2001:0db8:0:f101::1 to eth0 with the prefix 64.

29. Delete an IPv6 Address from a Network Interface

Deleting an IPv6 address from a network interface is pretty easy once you can assign them. All you need to do for this is use the del argument instead of the add. Check out the next example to understand how this works in ifconfig.

$ sudo ifconfig eth0 del 2001:0db8:0:f101::1/64

This command will delete the IPv6 address we assigned to eth0 earlier.

30. Enabling Trailers for Ethernet Interface

The trailers option in ifconfig allows Linux users to enable or prevent negotiations for trailer encapsulation of TCP packets. Use the following command to allow trailer encapsulation.

$ sudo ifconfig eth0 trailers

Note that this option is only available for the ethernet interface.

31. Disable Trailers for Ethernet Interface

It’s very easy to disable trailers for the ethernet interface in Linux. Simply prepend a – before the option to disable it from the command line.

$ sudo ifconfig eth0 -trailers

You can use this Linux ifconfig command to disable trailers for the ethernet interface eth0.

32. Assign Point to Point Connections

Point to point connections refers to the communication between two nodes on the world wide web. You can use the Linux ifconfig command to do this pretty quickly. The next example shows you how to enable point to point connections on a Linux machine.

$ sudo ifconfig sl0 172.16.62.1 point-to-point 172.16.62.2

The above command enables the sl0 interface to establish point-to-point communication between the two IP addresses. However, we’ll suggest you refrain from this as it will enable automatic tunneling from anywhere on the internet. Instead, you can use the Linux route command.

33. Delete Point to Point Connections

When you set up point-to-point connections for an interface, it creates a direct link between two machines with nobody else listening to it. You can use the below ifconfig command to delete this connection anytime you want.

$ sudo ifconfig sl0 172.16.62.1 -point-to-point 172.16.62.2

So, all you need to do is add a preceding sign to the point-to-point argument. It will remove the connection you created earlier.

34. Creating Tunnels with Linux Ifconfig Commands

In networking terms, a tunnel is a connection made over a network between two computer devices. The ifconfig command in Linux allows users to set up custom tunnels for their SIT (IPv6-in-IPv4) devices. Check out the below example to understand how this works.

$ sudo ifconfig sit0 up

First, we’re bringing up the generic tunnel device sit0 for our machine.

$ sudo ifconfig sit0 add 2002:80b0:b807::1/16

Here, 2002:80b0:b807::1 is the local 6to4 address. Now, all we need to do is add this route to the global IPv6 network using the all-6to4-relay.

$ sudo route -A inet6 add 2000::/3 gw ::192.88.99.1 dev sit0

35. Removing Tunnels

You can use the below ifconfig commands to remove the tunnel created earlier. First, remove the route through the 6to4 tunnel using the route command.

$ sudo route -A inet6 del 2000::/3 gw ::192.88.99.1 dev sit0

Now, remove the local 6to4 address of the sit0 interface.

$ sudo ifconfig sit0 del 2002:80b0:b807::1/16

Finally, shut down the generic tunnel device. Make sure no one is using this before proceeding.

$ sudo ifconfig sit0 down

36. Set a New Length for Transmission Queue

The Linux ifconfig utility allows users to assign custom transmission queue lengths for their network interfaces. It is especially suitable for slower devices with high latency, such as modem links and ISDN. The below command demonstrates how to set the transmission queue length of the eth0 interface to a new value.

$ sudo ifconfig eth0 txqueuelen 5000

This Linux ifconfig command will set the transmission length of eth0 as 5000. To save this value permanently for this interface, you need to edit the file /etc/rc.locale. Open this using your favorite Linux text editor and add the following lines at the end of the document.

/sbin/ifconfig eth0 txqueuelen 5000

37. View Transmission Errors

You can view the transmission errors of your network interfaces pretty quickly using the below command. Here, the filtering is performed by the grep command.

$ ifconfig | grep errors

This command will output all lines that contain the word errors. It shows all the errors in your transmitted or received packets.

38. View Your External IP Address

The external IP address is used by every device on the internet to recognize each other. Your ISP provider assigns it. You can use the below command to find out your external IP address very quickly.

$ curl ifconfig.me

Run this command in your terminal, and it will present you with your external IP address.

39. Get a Short List of All Available Options

Since the Linux ifconfig utility offers a lot of options, it’s quite easy to forget them. You can use the below command to view a concise list of all possible command-line options for this tool.

$ ifconfig --help 5

It will provide a narrowed down list of all available options to ifconfig and also outline the address families alongside the hardware types.

40. Get Full Documentation

The man page of ifconfig covers all the possible options and their use cases of this utility. You can consult the man page for this information, as shown below.

$ man ifconfig

This command will list the manual page of ifconfig. Here, you will find all the information you need regarding the various ifconfig commands.

Ending Thoughts


Since handling network interfaces takes a considerable amount of work hours, you need to master these Linux ifconfig commands to excel at networking. Our editors have gone over numerous references before selecting these commands for you. You can try these commands directly in your terminal, but we’d suggest you fire up a virtual machine. In this way, you won’t mess up your network interfaces when trying out new things. You can even use docker containers or Linux emulators if you want. Hopefully, we’ve been able to provide the insights you were looking for. Leave us your thoughts on this guide.

10 COMMENTS

  1. Although people seem to argue over ifconfig’s validity, i don’t think they’re correct necessarily. People should have the freedom to choose any tools they want – ip or ifconfig whatever. I mean that’s all the fuss about Linux and open source right? FREEDOM?

    Why can’t you stand the fact that someone’s using a deprecated command-line tool? What’s the problem with riding the bike even if they can fly in planes? This ‘elitist’ mentality is the reason the community is divided into so many factions. Great job guys!

  2. The newest LTS version of Ubuntu does not have this command installed by default. It was replaced by ip as well as other traditional commands. Releasing such article does nobody no good.

  3. I am a journalist! Congrats, managed to write an article about an outdated command in the least useful format, that is, using paragraphs and detailed storytelling instead of a list of command arguments and their usage.

    This is why we can’t have nice things – this article is the same as any online recipe nowadays where you have to get through 300 pages of irrelevant and uninteresting storytime to get to the actual sodding recipe.

    Cg again

  4. Dude, ifconfig is deprecated in Linux for decades!
    And that for good reasons. Spreading this kind of information does nobody any good.

    Because if the complexity of Linuxes network capabilities, the ifconfig command and it’s arcane syntax are no longer able to express the reality of your setup.
    Just don’t use it. It’s just a very limited compatibility layer.

    The ip command (from iproute2) has a non-insane syntax and tells the truth.

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Exit mobile version