configure multiple IP for a same network interface

October 15th, 2006 mysurface Posted in ifconfig, Network, ping | Hits: 32493 | No Comments »

To configure an IP for network interface eth0, do this

ifconfig eth0 192.168.1.88 netmask 255.255.255.0 up

How about I need another one? For linux, you can do IP alias by given an additional name for network interface by adding : and a number start from 1, such as

eth0:1 eth0:2 eth0:3

Therefore configure a second IP for eth0, do this

ifconfig eth0:1 10.0.0.88 netmask 255.0.0.0

Usually, if you wanna check for the network interface whether it can access to internet, you can ping a well known host. I usually pick yahoo or google.

ping www.yahoo.com

If it return that means it works. But what if i have second IP or I have a second interface, what can I do? You can specified your interface name with -I, for this case, I have 10.0.0.88 (eth0:1), I can do this

ping -I eth0:1 www.yahoo.com

The example works for linux but for BSD or other Unix variant, check out the manual for more details.

Leave a Reply