Email This List Email This List Print This List Print This List

Con­fig­ure your Linux net­work inter­face

1. View Net­work Set­tings of an Eth­er­net Adapter

Ifcon­fig, when invoked with no argu­ments will dis­play all the details of cur­rently act­ive inter­faces. If you give the inter­face name as an argu­ment, the details of that spe­cif­ic inter­face will be dis­played.

# 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. Dis­play Details of All inter­faces Includ­ing Dis­abled Inter­faces

# ifconfig -a

3. Dis­able an Inter­face

# ifconfig eth0 down

4. Enable an Inter­face

# ifconfig eth0 up

5. Assign ip-address to an Inter­face

Assign as the IP address for the inter­face eth0.

# ifconfig eth0

Change Sub­net mask of the inter­face eth0.

# ifconfig eth0 netmask

Change Broad­cast address of the inter­face eth0.

# ifconfig eth0 broadcast

Assign ip-address, net­mask and broad­cast at the same time to inter­face eht0.

# ifconfig eth0 netmask broadcast


Edit /​etc/​hostname, enter:
# cat /etc/hostname
Sample ip con­fig:

Edit /​etc/​network/​interfaces, enter:
# cat /etc/network/interfaces
Sample stat­ic ip con­fig:

iface eth0 inet static

Edit /etc/resolv.conf and setup DNS serv­ers, enter:
# cat /etc/resolv.conf
Sample dns stat­ic IP con­fig­ur­a­tions:


Finally, you need to restart the net­work­ing ser­vice under Debi­an /​ Ubuntu Linux, enter:
# /etc/init.d/networking restart

Type the fol­low­ing com­mands to veri­fy your new setup, enter:
# ifconfig eth0
# route -n
# ping

6. Change MTU

This will change the Max­im­um trans­mis­sion unit (MTU) to XX. MTU is the max­im­um num­ber of oct­ets the inter­face is able to handle in one trans­ac­tion. For Eth­er­net the Max­im­um trans­mis­sion unit by default is 1500.

# ifconfig eth0 mtu XX

7. Promis­cu­ous mode

By default when a net­work card receives a pack­et, it checks wheth­er the pack­et belongs to itself. If not, the inter­face card nor­mally drops the pack­et. But in promis­cu­ous mode, the card doesn’t drop the pack­et. Instead, it will accept all the pack­ets which flows through the net­work card.

Super­user priv­ilege is required to set an inter­face in promis­cu­ous mode. Most net­work mon­it­or tools use the promis­cu­ous mode to cap­ture the pack­ets and to ana­lyze the net­work traffic.

Fol­low­ing will put the inter­face in promis­cu­ous mode.

# ifconfig eth0 promisc

Fol­low­ing will put the inter­face in nor­mal mode.

# ifconfig eth0 -promisc

Related Post

admin has written 133 articles