Pages

Thursday, October 4, 2012

Ifconfig


Ifconfig or interface configuration is a system administration utility in Unix-like operating systems to configure, control, and query TCP/IP network interface parameters.Ifconfig gives you the various details like Ip address , Mast address e.t.c.This can also be used in disabling and enabling a given configuration.

The following example output samples display the state of a single active interface each on a Linux-based host (interface eth0).

[xprk477@omhq13aa ~]$ /sbin/ifconfig eth0
eth0   Link encap:Ethernet  HWaddr 02:00:30:00:03:AA
          inet addr:167.132.86.98  Bcast:167.132.86.127  Mask:255.255.255.224
          inet6 addr: fe80::30ff:fe00:3aa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:837810597 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1087417750 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:611883055593 (569.8 GiB)  TX bytes:705522440469 (657.0 GiB)

·Link encap: the type of the hardware physical medium supported by this interface (Ethernet, in this case)
·HWaddr: the unique identifier of the NIC card. Every NIC card has a unique identifier assigned by the manufacturer, called MAC address. The MAC value never changes.
·Mask: the netmask
·inet addr: the IP address attached to the interface
·RX packets: the number of packets received by this interface
·TX packets: the number of packets sent
·errors: the number of errors in sending or receiving

up/down – enables or disables a specific interface. You can use the down to shutdown an interface like,

 ifconfig eth0 down

If we need to bring that up we can use,

 ifconfig eth0 up

add – sets a specific IP address for the interface. To set an IP address of 192.170.1.121 to the interface eth0, we can use

# ifconfig eth0 add 192.178.1.121

netmask – sets the netmask parameter of the interface. Here is an example where you can set the netmask of the eth0 interface to 255.255.255.0

# ifconfig eth0 netmask  255.255.255.0

Few More Examples Include

Assign ip-address to an Interface
Assign 172.178.3.2 as the IP address for the interface eth0.
# ifconfig eth0 172.178.3.2

Change Subnet mask of the interface eth0.
# ifconfig eth0 netmask 255.255.255.0

Change Broadcast address of the interface eth0.
# ifconfig eth0 broadcast 172.178.2.254

Assign ip-address, netmask and broadcast at the same time to interface eht0.
# ifconfig eth0 172.178.3.2 netmask 255.255.255.0 broadcast 172.178.2.254

Happy Learning , More To Come