Best Linux Ifconfig command with examples

In this article we will explain the ifconfig command on Linux. Ifconfig is a simple command line utility on Linux that checks and configures network interfaces. Hence the full form of ifconfig Interface Configuration, With this command you can call up network information such as IP address (both IPV4 and IPV6), physical address (MAC address), subnet mask, broadcast address, MTU, metric, packets, drops and all connected network interface cards (e.g. eth0 ) list, eth1, lo, WLANs) etc.

Best Linux Ifconfig command with examples

Best Linux Ifconfig command with examples:

In this article I will show you the 10 most important ifconfig commands that can be used by any Linux administrator.

Configure the IP address with the ifconfig command

You can configure the IP address on Linux using the ifconfig command. Here I have an ethernet connection, i.e. ens33, So let’s configure the IP address 10.40.234.150 in the ens33, See the following command.

[email protected]ubuntu:~$ sudo ifconfig ens33 10.40.234.150   # Configure IP Address

Configure the IP address and the subnet mask

Use the following command to configure the IP address and subnet mask.

[email protected]:~$ sudo ifconfig ens33 10.40.234.150 netmask 255.255.0.0   # Configure IP Address & Subnet Mask

Configure the IP address, the subnet mask and the broadcast address at the same time with the Linux command ifconfig

You can use the ifconfig command to configure the IP address, subnet mask, and broadcast address at the same time with a single command. Here we used the syntax netmask for setting the subnet mask address and the syntax transmission to set the broadcast address. See the following command.

[email protected]:~$ sudo ifconfig ens33 10.40.234.150 netmask 255.255.0.0 broadcast 10.40.234.255

Check the network information of all connected network interfaces

Check the network information of all currently connected network interfaces with the following command. This includes the various interfaces such as ens33, lo (loopback), WLAN (wireless LAN) etc.

[email protected]:~$ ifconfig   # List all Network Interfaces
ens33     Link encap:Ethernet  HWaddr 00:0c:29:ff:cd:2e  
          inet addr:192.168.0.103  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::b396:d285:b5b3:81c3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:851 errors:0 dropped:0 overruns:0 frame:0
          TX packets:525 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:710566 (710.5 KB)  TX bytes:50788 (50.7 KB)

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:266 errors:0 dropped:0 overruns:0 frame:0
          TX packets:266 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21250 (21.2 KB)  TX bytes:21250 (21.2 KB)

You can also use the ifconfig command with an argument -on to check the details of all connected / available network connections.

[email protected]:~$ ifconfig -a

Also Read: Complete Unix commands and basic Linux commands with examples for beginners

We have two other commands in Linux to check the IP address. I mentioned both commands below.

Command 1:

[email protected]:~$ ip a   # To check IP Address

Command 2:

[email protected]:~$ ip addr   # To check IP Address

Check the IP address with other information about a specific Ethernet connection

You can use the ifconfig command to check the IP address and other network-related information for a particular Ethernet connection. Here I check the configuration of ens33, See the following command

[email protected]:~$ ifconfig ens33   # Check IP Address of a Particular Interface
ens33     Link encap:Ethernet  HWaddr 00:0c:29:ff:cd:2e  
          inet addr:192.168.0.103  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::b396:d285:b5b3:81c3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:851 errors:0 dropped:0 overruns:0 frame:0
          TX packets:525 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:710566 (710.5 KB)  TX bytes:50788 (50.7 KB)

Create a selection list of the currently connected Ethernet connections

To display the shortlist of the current Ethernet connections, you can use the ifconfig command with an argument -s, Here I have two ethernet connections, i.e. ens33 & lo (Localhost) See the following command.

[email protected]:~$ ifconfig -s   # Short List of current Ethernet Connections
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33      1500 0       862      0      0 0           530      0      0      0 BMRU
lo        65536 0       268      0      0 0           268      0      0      0 LRU

Configure the MTU (Maximum Transfer Unit) for an Ethernet connection

MTU stands for Maximum Transfer Unit and defines how many packets an interface can transfer. You can set and configure MTU for an Ethernet connection using the ifconfig command. Here I set the MTU value for my ens33 interface to 1200. See the following command.

[email protected]:~$ sudo ifconfig ens33 mtu 1200    # Configure MTU for a Interface

Activate the Ethernet connection with the Linux command ifconfig

The following ifconfig command enables or enables an Ethernet connection. You can also use it ifup ens33 command to do the same.

[email protected]:~$ sudo ifconfig ens33 up   # Enable/Activate the Ethernet Connection

Deactivate the Ethernet connection with the ifconfig command

To disable or disable the Ethernet connection, you can use the following command. You can also use it ifdown ens33 command to do the same.

[email protected]:~$ sudo ifconfig ens33 down   # Disable/Deactivate the Ethernet Connection

Read also: How to find your IP address (public IP address) in Ubuntu 19.04

Help commands and manuals for Linux command ifconfig

For more information about the ifconfig command and its arguments, you can use the following command.

[email protected]:~$ ifconfig --help   # for more commands & arguments on ifconfig

OR You can read the manual page of the ifconfig command with the following command.

[email protected]:~$ man ifconfig   # Manual page of ifconfig

That’s all. In this article we explained Best Linux ifconfig Command with examples. I hope you like this article. If you like this article, just share it. If you have any questions about this article, please comment.

Sidebar