ifconfig command

Ifconfig command :- 

Whenever we connect one computer to another computer or other device, then we need IP address. And every computer has a network interface card and we assign IP address to this card. 

With the help of this command, it is used to give IP address and netmask to the network interface and enable or disable the network interface, so let us see how to do all this.

What is enabling or disabling a network interface? 

Allowing the data to be received over the network or sent over the network is called enabling interface, on the contrary, the process is called disabling.

Syntax: 

ifconfig  [options]  [interface]

1. How to view network interface card information ?

Syntax:

$ifconfig  -a

With the help of -a (--all) option, ifconfig displays all network interfaces whether enabled or disabled.









In the picture you can see that there are three network interfaces eth0,lo and wlan0.  Above red line in wlan0 is written UP in flags=4163<UP, BROADCAST, RUNNING, MULTICAST> it means it is enabled and likewise lo is also enabled But as can be seen in eth0 here flag=4098<BROADCAST, MULTICAST> does not have UP which means it is disabled. Next we will see how to enable and disable it.


2. How to find out how many network interfaces are enabled.

When we use this command without any option then it displays about all enabled network interfaces.


$ifconfig 

3.$ifconfig -s :

The ifconfig command, with the help of the option -s (--sort), shows all the enabled network interfaces in a small and organized form.



4. ifconfig -a -s :

Let's understand -a -s options, both - a(all) and -s (sort) are present in it, it means enable or disable it displays all as sort.




4. How to enable network interface ?

$ifconfig eth0 up 

This command enables the network interface so that the computer can connect to a network or internet. 

eth0 : is name of network interface.

up : used for enable network interface.









5. How to disable network interface ?

Syntax:

$ifconfig wlan0 down

This command disables the network interface.

wlan0 : name of network interface .

down : used for disable network interface.








6. How to assign IP address and netmask ?

Syntax:

$ifconfig [network interface] [IP address]




You can see on the screen that the IP address of eth0 is : 172.16.25.125 Now we change its IP address to : 172.16.25.126.

Syntax :-

ifconfig eth0 172.16.25.126 





We have successfully assigned the IP address 172.16.25.126 to eth0.

I have tried to make it easy to understand by taking the Linux manual page as a reference.

If you liked this article, please help others by sharing.If there is anything incorrect in this or it needs more improvement then you can comment me in the comment box below or contact at query.me

Comments

Popular posts from this blog

ls command

wc Command