Linux ifconfig is a network management tool that helps you to check the IP addresses of Linux systems as well as configure network interfaces. Let’s dive in and see how this popular command is used.
Table of Contents
- 1 Linux ifconfig command without any options
- 2 Display ifconfig Output in a Short Format
- 3 Display Status of a Single Network Interface
- 4 Enable/Disable Network Interfaces using ifconfig
- 5 View all Network Interfaces using “ifconfig -a” Option
- 6 Enable and Disable Promiscuous Mode on a Network Interface
- 7 Configure IP Address and Netmask of a Network Interface
- 8 Change mtu value using ifconfig
Linux ifconfig command without any options
The ifconfig command without any arguments displays the status of all the network interfaces associated with the Linux system.
$ ifconfig
Sample Output
Display ifconfig Output in a Short Format
To display ifconfig output in short format use the -s
option.
$ ifconfig -s
Sample output
Display Status of a Single Network Interface
If you want to check the status of a specific network interface, use the syntax:
$ ifconfig [interface_name]
For instance, to display the status of interface enp0s3
, run:
$ ifconfig enp0s3
Enable/Disable Network Interfaces using ifconfig
Sometimes, you may want to reset your network interfaces. Linux ifconfig command can be used to disable or bring up network interfaces.
To bring down a network interface, run the command
$ ifconfig [interface_name] down
For example, to bring down interface enp0s3
execute the command:
$ ifconfig enp0s3 down
when you check the statistics using the ifconfig
command, the disabled interface will not appear in the output. For example, the enp0s3
interface will not be displayed.
To bring the interface up execute:
$ ifconfig enp0s3 up
This time, round, the interface will show up upon running the ifconfig
command.
Sample output
View all Network Interfaces using “ifconfig -a” Option
Using the ifconfig command, you can view all interfaces whether they are up or down. To do this, use the -a
option as shown
$ ifconfig -a
Sample output
Enable and Disable Promiscuous Mode on a Network Interface
Promiscuous mode refers to an operational mode that allows a network adapter to access and view all packets in a network. In this mode, the adapter does not filter packets.
To enable promiscuous mode use the syntax:
$ ifconfig [network_interface] promisc
For example:
$ ifconfig enp0s3 promisc
To disable promiscuous mode execute:
$ ifconfig enp0s3 -promisc
Sample output
Configure IP Address and Netmask of a Network Interface
Linux ifconfig command can also be used to temporarily configure the IP address and netmask of a network adapter. The syntax is as shown:
$ ifconfig [network_interface] [IP-address] netmask [subnet mask]
For instance,
$ ifconfig enp0s3 192.168.43.100 netmask 255.255.255.0
You can later confirm this using the ifconfig
command.
Change mtu value using ifconfig
You can change mtu (Maximum Transmission Unit) value using the syntax:
$ ifconfig [interface_name] mtu [mtu-value]
For instance:
$ ifconfig enp0s3 mtu 800
These are some of the most commonly used ifconfig
commands. Your feedback on this guide is most welcome.