Using ifconfig

15414

What is ifconfig???

Well, ifconfig command has been used for years to manage network interface cards.Its is easy and small but gets the job done.

Using ifconfig

If ifconfig is used without any parameters it will show all the information of all the network interfaces(loopback,eth0,etc…). Information like : Link encap, hardware address and most especially RX packets and TX packets since with from these you can determine whether there is any errors in the network.

To display all information of all the network interfaces simply type:

ifconfig

However, to display information of a specific network interface like eth0 , simply type:

ifconfig eth0

 

ifconfig can be used not only to display network information but also to change them.

 

for example if you want to change the current ip address of eth0 from 192.168.1.2 to 192.168.1.10 you can simply type this command in the terminal to do so:

ifconfig eth0 192.168.1.10 up

However, you can pass some extra parameters while changing the ip address like subnet mask eg:

ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up

You can also bring a specific network up(on) or down(off) eg:

ifconfig eth0 up

ifconfig eth0 down

Using Virtual IP Addresses with ifconfig

Another rather useful way of using ifconfig is to add virtual IP addresses, which are just secondary IP addresses that are added to a network card. A network board with virtual IP addresses can listen to two different IP addresses, which is useful if you are configuring serv- ices on your server that all need their own IP addresses.

You can also use the virtual IP address within the same address range or on a different one. To add a virtual IP address, add :n where n is a number after the name of the network interface.For example, ifconfig eth0:0 10.0.0.10 adds the address 10.0.0.10 as a virtual IP address to eth0. The number after the colon must be unique, you can add a second virtual IP address with ifconfig eth0:1 10.0.0.20, and so on.