10 BEST LINUX IFCONFIG COMMAND WITH EXAMPLES
Introduction
In this article we are going to discuss on Linux ifconfig command. Ifconfig is a simple command line utility in Linux used to check and configure network interfaces. Hence the full form of ifconfig is Interface Configuration. By using this command you can get network information like IP Address (both IPV4 & IPV6), Physical Address (MAC Address), Subnet Mask, Broadcast address, MTU, Metric, Packets, Drops, lists all connected network interface cards (eg: eth0, eth1, lo, wlans)…etc…
In this article I will show you the 10 most important ifconfig command which is usable for every Linux administrators.
Configure IP address using ifconfig command
You can configure IP Address in Linux using ifconfig command. Here I have a Ethernet connection i.e. ens33. So let’s configure the IP Address 10.40.234.150 in ens33. Refer the command below.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 10.40.234.150 # Configure IP Address
Configure IP Address & Subnet Mask
To configure IP Address and Subnet Mask use the below command.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 10.40.234.150 netmask 255.255.0.0 # Configure IP Address & Subnet Mask
Configure IP Address, Subnet Mask & Broadcast Address at a time using Linux ifconfig command
We can use ifconfig command to configure IP Address, Subnet Mask & broadcast address at a time using single command. Here we used the syntax netmask to set the Subnet Mask address & the syntax broadcast to set the broadcast address. Refer the command below.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 10.40.234.150 netmask 255.255.0.0 broadcast 10.40.234.255
Check Network Information of all connected Network Interfaces
Check network information’s of all currently connected network interfaces using below command. This includes the different interfaces like ens33, lo (Loopback), wlan (Wireless LAN)…etc…
elinuxbook@ubuntu:~$ 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 Linux ifconfig command with argument -a to check details of all connected/available network connections.
elinuxbook@ubuntu:~$ ifconfig -a
Also Read :
- COMPLETE UNIX COMMANDS AND BASIC LINUX COMMANDS WITH EXAMPLES FOR BEGINNERS
- MOST USEFUL LINUX PING COMMAND (PING UTILITY) WITH EXAMPLES
We have two more commands in Linux to check IP Address. Here below I have mentioned both commands.
Command 1 :
elinuxbook@ubuntu:~$ ip a # To check IP Address
Command 2 :
elinuxbook@ubuntu:~$ ip addr # To check IP Address
Check IP Address with other Information’s of a particular Ethernet Connection
We can use Linux ifconfig command to check IP Address and other network related information’s of a particular Ethernet connection. Here I am going to check the configuration of ens33. Refer the command below
elinuxbook@ubuntu:~$ 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 short list of currently connected Ethernet Connections
To show the short list of current Ethernet connections you can use Linux ifconfig command with argument -s. Here I have two Ethernet connections i.e. ens33 & lo (Localhost) Refer the command below.
elinuxbook@ubuntu:~$ 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 Maximum Transfer Unit (MTU) for a Ethernet Connection
MTU is stands for Maximum Transfer Unit which defines how much packets a interface can transfer. You can decide and configure MTU for a Ethernet connection using ifconfig command. Here I am going to set MTU value as 1200 for my interface ens33. Refer the command below.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 mtu 1200 # Configure MTU for a Interface
Enable Ethernet connection using Linux ifconfig command
The below ifconfig command will enable or activate a Ethernet connection. You can also use ifup ens33 command to do the same.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 up # Enable/Activate the Ethernet Connection
Disable Ethernet connection using ifconfig command
To disable or deactivate the Ethernet connection you can use the below command. You can also use ifdown ens33 command to do the same.
elinuxbook@ubuntu:~$ sudo ifconfig ens33 down # Disable/Deactivate the Ethernet Connection
Help commands & Manuals for Linux ifconfig command
For more information’s on ifconfig command with it’s arguments you can use the below command.
elinuxbook@ubuntu:~$ ifconfig --help # for more commands & arguments on ifconfig
OR you can read the manual page of Linux ifconfig command using below command.
elinuxbook@ubuntu:~$ man ifconfig # Manual page of ifconfig
Here I have included all possible Linux ifconfig command. If you found this article useful then Like us, Share this post on your preferred Social media, Subscribe our Newsletter OR if you have something to say then feel free to comment on the comment box below.
By the way the ifconfig command is now deprecated. The command ip is the command to be used in future.