Linux ifconfig Command Examples

Filed Under: UNIX/Linux

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.

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

Linux ifconfig Command

Display ifconfig Output in a Short Format

To display ifconfig output in short format use the -s option.

$ ifconfig -s

Sample output

ifconfig output in short format

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

check status of  Network Interface using ifconfig

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.

Ifconfig Disable A Network Interface

To bring the interface up execute:

$ ifconfig enp0s3 up

This time, round, the interface will show up upon running the ifconfig command.

Sample output

Ifconfig Enable A Network Interface

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

view all network interfaces ifconfig -a option

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

Ifconfig Enable And Disable Promiscuous Mode

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.

Ifconfig Set IP Address Of A Network Interface

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages