≡ Menu

Ifconfig: 7 Examples To Configure Network Interface

Ethernet Card
Photo courtesy of new1mproved

This article is written by Lakshmanan G

Ifconfig command is used to configure network interfaces. ifconfig stands for interface configurator. Ifconfig is widely used to initialize the network interface and to enable or disable the interfaces.

In this article, let us review 7 common usages of ifconfig command.

1. View Network Settings of an Ethernet Adapter

Ifconfig, when invoked with no arguments will display all the details of currently active interfaces. If you give the interface name as an argument, the details of that specific interface will be displayed.

# ifconfig eth0

eth0   Link encap:Ethernet  HWaddr 00:2D:32:3E:39:3B
inet addr:  Bcast:  Mask:
inet6 addr: fe80::21d:92ff:fede:499b/64 Scope:Link
RX packets:977839669 errors:0 dropped:1990 overruns:0 frame:0
TX packets:1116825094 errors:8 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2694625909 (2.5 GiB)  TX bytes:4106931617 (3.8 GiB)
Interrupt:185 Base address:0xdc00

2. Display Details of All interfaces Including Disabled Interfaces

# ifconfig -a

3. Disable an Interface

# ifconfig eth0 down

4. Enable an Interface

# ifconfig eth0 up

5. Assign ip-address to an Interface

Assign as the IP address for the interface eth0.

# ifconfig eth0

Change Subnet mask of the interface eth0.

# ifconfig eth0 netmask

Change Broadcast address of the interface eth0.

# ifconfig eth0 broadcast

Assign ip-address, netmask and broadcast at the same time to interface eht0.

# ifconfig eth0 netmask broadcast

6. Change MTU

This will change the Maximum transmission unit (MTU) to XX. MTU is the maximum number of octets the interface is able to handle in one transaction. For Ethernet the Maximum transmission unit by default is 1500.

# ifconfig eth0 mtu XX

7. Promiscuous mode

By default when a network card receives a packet, it checks whether the packet belongs to itself. If not, the interface card normally drops the packet. But in promiscuous mode, the card doesn’t drop the packet. Instead, it will accept all the packets which flows through the network card.

Superuser privilege is required to set an interface in promiscuous mode. Most network monitor tools use the promiscuous mode to capture the packets and to analyze the network traffic.

Following will put the interface in promiscuous mode.

# ifconfig eth0 promisc

Following will put the interface in normal mode.

# ifconfig eth0 -promisc

This article was written by Lakshmanan G. He is working in bk Systems (p) Ltd, and interested in contributing to the open source. The Geek Stuff welcomes your tips and guest articles.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • A Ubuntu Lover November 20, 2012, 6:30 am

    An excellent tutorial. Good explanations.

  • anand October 29, 2013, 10:31 am

    hi, u r helping a lot for the linux system administrators. thanks.

  • Andy Middleton December 28, 2013, 5:06 pm

    Thank you for the very helpful information. It was very useful in getting the IP address changed on my Asterisk server without having to reload the system. Thanks again

  • vaibhav February 13, 2015, 2:55 am

    Hi ,
    Can you tell me how can interact with System Hardware on Ubuntu using Java.Please give me any solutions.