ifconfig utility for linux users

Satish Tiwary's picture
ifconfig command in linux

Ifconfig stands for "Interface Configuration" .It is a utility for Linux machines  to configure,assign,add,delete,control and query network interface in Unix/Linux machine.

Common Linux users uses IFCONFIG command to assign ip address and netmask to an interface or to disable or enable a given interface.

Lets see how a Linux admin or a linux geek can have fun with this simple command.

slashroot is today will explain the power, the real strength of ifconfig command.

 

1.Show Network Devices and configuration and all network setting

[root@satish ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1B:B9:B3:BD:4F 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:201 Base address:0xc00
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:16436  Metric:1
          RX packets:9439 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9439 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5524963 (5.2 MiB)  TX bytes:5524963 (5.2 MiB)
ppp0      Link encap:Point-to-Point Protocol 
          inet addr:106.219.181.163  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:8444 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8991 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:7785191 (7.4 MiB)  TX bytes:1164790 (1.1 MiB)

Explanation:Here clearly you can see the output of ifconfig command. It has displayed the information of network intefaces.

eth0: is my ethernet card

lo: is loopback address

ppp0:Point-to-point Protocol.

 

2.How to Display the Information of all network interface

#ifconfig -a

[root@satish ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:1B:B9:B3:BD:4F 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:201 Base address:0xc00
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:16436  Metric:1
          RX packets:10033 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10033 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5555990 (5.2 MiB)  TX bytes:5555990 (5.2 MiB)
ppp0      Link encap:Point-to-Point Protocol 
          inet addr:106.219.181.163  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:8468 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9090 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:7787427 (7.4 MiB)  TX bytes:1170752 (1.1 MiB)
sit0      Link encap:IPv6-in-IPv4 
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Note:Now a days ip command is getting more marks in Linux world, when you go through the man page of ip command you will find that it is more easy and it also have the capacity to do the same and thats little bit tricky too.

 

Lets see How one can see network Devices and Configuration through ip command in Linux.

[root@satish ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:1b:b9:b3:bd:4f brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 brd 192.168.1.255 scope global eth0
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0
4: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 3
    link/ppp
    inet 106.219.181.163 peer 10.64.64.64/32 scope global ppp0

We have one more command with Ip to show more about network configuration and Devices

[root@satish ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:1b:b9:b3:bd:4f brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0
4: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 3
    link/ppp

 

3.View the Network configuration of a Specific Interface

[root@satish ~]# ifconfig ppp0
ppp0      Link encap:Point-to-Point Protocol 
          inet addr:106.219.181.163  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:8980 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9758 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:8289652 (7.9 MiB)  TX bytes:1240309 (1.1 MiB)

4.How to Enabale a Network Interface

#ifup eth0

#ifconfig eth0 up

 

5.How to Disable a Network Interface

#ifconfig eth0 down

OR

 

#ifdown eth0

 

6.How to assign ip to a Network Interface

#ifconfig eth0 192.168.1.1

#ip address add 192.168.1.1 dev eth0

 

7.How to assign Netmask to a network interface

#ifconfig eth0 netmask 255.255.255.0

 

8.How to Delete a ip address

#ip addr del 192.168.1.1/24 dev eth0

 

 

9.How to assign everything(ip address,netmask and network up) in a single command line.

#ifconfig eth0 netmask 255.255.255.0 up

 

 

10.How to assign a Broadcast address to a network interface

#ifconfig eth0 broadcast 192.168.1.255

 

Note:Broadcaste address is a 32 bit address pattern in which all host bits are "1"

 

11.How to assign all ip address,netmask and broadcast address at a time

#ifconfig etho 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255

 

12.How to change the Mac Address of a Network Interface card

 

#ifconfig eth0 hw ether FF:GG:HH:II:JJ:KK

 

13.How to add a new alias to a network interface

#ifconfig eth0:0 192.168.1.100

 

14.How To View or Verify whether New alias set or not on network interface

[root@satish ~]# ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:1B:B9:B3:BD:4F 
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          Interrupt:201 Base address:0xc00

15.How to remove alias network

#ifconfig eth0:0 down

 

16.How to change MTU(Maximum Transmission Unit) for a network interface

#ifconfig mtu 1000

 

17.How to enable Promiscuous mode

#ifconfig eth0 promisc

 

18.How to Disable Promiscuous mode

#ifconfig eth0 -promisc

 

what is Promiscuous mode?

answer: Promiscous mode is used to accept all the packets that flows through  the NIC(Network Interface Card)

 

Most of today hacking and network capturing tools used this mode to capture and analyze the packets that flow through the Network Interface card.

 

What happens in a Normal Mode?

In a Normal mode whenever a packet received by a NIC,it verify that whether the packet belongs to itself or not. If it's not, it drops the packet normaly, while it's not so in Promiscuous mode.

 

How to get your external IP Address?

[root@localhost ~]# curl ifconfig.me
106.223.44.33
[root@localhost ~]#

 

 

Dear Readers if you have any suggestion regarding this post slashroot welcome you to share your knowledge.

Rate this article: 
Average: 5 (10 votes)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.