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.

[root@LinuxServer ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 44:87:FC:A4:C5:DD
inet addr: Bcast: Mask:
inet6 addr: fe80::4687:fcff:fef4:458d/64 Scope:Link
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)

lo Link encap:Local Loopback
inet addr: Mask:
inet6 addr: ::1/128 Scope:Host
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

[root@LinuxServer ~]# ifconfig -a //Will show all up and down interfaces
[root@LinuxServer ~]# 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

[root@LinuxServer ~]# ifconfig eth0 up //Enable eth0
[root@LinuxServer ~]# ifconfig eth0 down //Disable eth0

3) Configure IP address and subnet mask

[root@LinuxServer ~]# ifconfig eth0 netmask

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

[root@LinuxServer ~]# ifconfig eth0
[root@LinuxServer ~]# ifconfig eth0 netmask

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.

[root@LinuxServer ~]# ifconfig eth0 arp //Enable arp
[root@LinuxServer ~]# 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.

root@LinuxServer ~]# ifconfig eth0 down
root@LinuxServer ~]# ifconfig eth0 22:67:df:1c:11:4f
root@LinuxServer ~]# 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.

[root@LinuxServer ~]# ifconfig eth0 promisc //Enable promisc mode
[root@LinuxServer ~]# 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

[root@LinuxServer ~]# ifconfig eth0 mtu 1700


Bobbin Zachariah 9:01 am


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

All comments are subject to moderation.