Linux ifconfig Command Options to Configure Interface

The ifconfig command can be used to display and set ip address to network interfaces in linux. Linux ifconfig command stands for interface configuration, it is used in the debugging and configuration of the network interfaces parameters.

1) Show network interface status

If you write the command without any options it will give you the status of all the up interfaces,as shown below. You can also find the MAC address binded to that interface in the output.

[[email protected] ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 44:87:FC:A4:C5:DD
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4687:fcff:fef4:458d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6053915 errors:0 dropped:11 overruns:0 frame:0
TX packets:757638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:794654447 (757.8 MiB) TX bytes:2415435778 (2.2 GiB)
Interrupt:17

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:3298 errors:0 dropped:0 overruns:0 frame:0
TX packets:3298 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:245808 (240.0 KiB) TX bytes:245808 (240.0 KiB)

You can also show a specific interface or all the up and down interfaces as shown below

[[email protected] ~]# ifconfig -a //Will show all up and down interfaces
[[email protected] ~]# ifconfig eth0 //Will show only eth0 status

2) Enable and disable interface

You can enable and disable the interface using the up and down options as below

[[email protected] ~]# ifconfig eth0 up //Enable eth0
[[email protected] ~]# ifconfig eth0 down //Disable eth0

3) Configure IP address and subnet mask

[[email protected] ~]# ifconfig eth0 192.168.1.30 netmask 255.255.255.0

The above example configure eth0 with ip address 192.168.1.30 with subnet mask 255.255.255.0, you can configure each parameter separately as below

[[email protected] ~]# ifconfig eth0 192.168.1.30
[[email protected] ~]# ifconfig eth0 netmask 255.255.255.0

5) Enable and disable ARP protocol to specific interface

ARP stands for the address resolution protocol, it is used for resolution of network layer addresses into link layer addresses.

[[email protected] ~]# ifconfig eth0 arp //Enable arp
[[email protected] ~]# ifconfig eth0 -arp //Disable arp

6) Change MAC address of interface

In order for this command to work, you should disable the interface and also the hardware vendor support this function. To change the MAC address do the following.

[email protected] ~]# ifconfig eth0 down
[email protected] ~]# ifconfig eth0 22:67:df:1c:11:4f
[email protected] ~]# ifconfig eth0 up

As I mentioned above this command will only work with NICs that supports that

7) Promiscuous option

The promisc mode is mostly used in monitoring, this command allow you to receive packets regardless you are the intended recipient.

[[email protected] ~]# ifconfig eth0 promisc //Enable promisc mode
[[email protected] ~]# ifconfig eth0 -promisc //Disable promisc mode

8) Changing the MTU

MTU stands for Maximum Transmission Unit, it is the size of the largest block of data that can be transmitted as a single unit, the default value is 1500, you can change it as the below example

[[email protected] ~]# ifconfig eth0 mtu 1700

 

Bobbin Zachariah 9:01 am

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.