ifconfig Command in Linux

Back

The ifconfig command ca display the current state of active adapters. It also can be used to assign network address and more. Run the ifconfig command by itself to reviews the active network adapters on the local system. If there seems be a missing network adapter, try the ifconfig -a command, which displays the current network adapters, whether or not they are currently active.

# ifconfig eth0

Configure a Network adapter with ifconfig

You can also use ifconfig to assign IP address information as well. For example the following command assigns the noted IP address and network mask to the eth0 (ethernet 0) network adapter.

# ifconfig eth0 192.168.122.150 netmask 255.255.255.0

The first parameter, eth0 ,tells you which interface is being configured. The next argument, 192.168.122.150, specifies the new IP address being assigned to this interface, To make sure the change worked, run the ifconfig eth0 command again to view its setting.

With the right switch ,the ifconfig command can modify a number of other settings for a selected network adapter.

Parameter                             Description

up                                        Activates the specified adapter

down                                   Deactivate the specified adapter

netmask address               Assign the address subnet mask

broadcast address             Assign the address as a broadcast address. Rarely required, since the default                                            
                                            broadcast address is standard for most current network

-arp                                     Deactivates the address resolution protocol (ARP) ,which collects network          
                                             adapter hardware address


Activate and Deactivate Network Adapters using ifconfig

It's possible to use the ifconfig command to activate and deactivate network adapters. For example, the following command deactivate and deactivate the first Ethernet adapter

# ifconfig eth0 down
# ifconfig eth0 up

ifconfig command call the appropriate configuration files and scripts in the /etc/sysconfig/network-scripts directory ,for details on how a network adapter is to be activated and deactivated.

For example, the ifup eth0 command brings up the first ethernet network adapter based on the ifcfg- eth0 configuration file and the ifcfg-eth script in the /etc/sysconfig/network-scripts directory.