search
top

How To Configure Network Interface Using IFCONFIG

Introduction

One of many useful commands to master as an administrator of Linux systems is the ifconfig command. Ifconfig command is used to configure network interfaces. Ifconfig is used to initialize the network interface and to enable or disable the interfaces.

Common Uses

Here are several common usages of ifconfig command.

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: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 10.102.21.76 netmask 255.255.254.0 broadcast 10.102.21.255
 ether 00:1e:4f:98:76:df txqueuelen 1000 (Ethernet)
 RX packets 1633574 bytes 1109841880 (1.0 GiB)
 RX errors 0 dropped 343 overruns 0 frame 0
 TX packets 189136 bytes 16446062 (15.6 MiB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
 device interrupt 21 memory 0xfebe0000-fec00000

Display Details of All interfaces

 $ ifconfig -a

Assign 192.168.1.3 as the IP address for the interface eth0

$ sudo ifconfig eth0 192.168.1.3

Change Subnet mask of the interface eth0

$ sudo ifconfig eth0 netmask 255.255.255.0

Change Broadcast address of the interface eth0

$ sudo  ifconfig eth0 broadcast 192.168.1.255

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

$ sudo ifconfig eth0 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255

Take Down an Interface

$ ifconfig eth0 down

Bring Up an Interface

$ ifconfig eth0 up

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. This usually will get change to correct netork communication issues. In this example we are changing the MTU to 1480.

$ sudo ifconfig eth0 mtu 1480

Some Un-Common Uses

Set NIC to 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. This is very useful in troubleshooting connection issues.

$ sudo ifconfig eth0 promisc

Remove NIC from Promiscuous mode

$ sudo  ifconfig eth0 -promisc

Conclusion

As you can see ifconfig is a very handy tool to have knowledge as a Linux administrator and is easy and quick to manage your systems.

2 Responses to “How To Configure Network Interface Using IFCONFIG”

  1. waqar says:

    eth0: flags=4163 mtu 1480
    inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
    inet6 fe80::8b44:4871:3b3:1fb7 prefixlen 64 scopeid 0x20
    ether 08:00:27:5f:17:79 txqueuelen 1000 (Ethernet)
    RX packets 9077 bytes 5081903 (4.8 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 6055 bytes 666365 (650.7 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73 mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10
    loop txqueuelen 1 (Local Loopback)
    RX packets 96 bytes 8528 (8.3 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 96 bytes 8528 (8.3 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    root@kali:~ sir still have the problem i never set static ip im trying from a year ago please help me sir

Leave a Reply

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

top