Sometimes you need to bind a second IP address to a Network Interface Card. Maybe you need access to another network temporarily or you just need to fix something that comes with a default address not on your network.
From Linux, you can execute the following command:
ifconfig eth0:1 192.168.5.16 netmask 255.255.255.0 up
NOTE: This will require ROOT (superuser) permissions!
This will add a second IP Address to your eth0 network interface.
Multiple IP Addresses on a Single NIC
In the previous section "Determining Your IP Address" you may have noticed that there were two interfaces: eth0 and wlan0. However, since I'm running two networks at home (192.168.8.x and 192.168.5.x, as well as the virtual network 192.168.230.x), I can assign an IP Address of 192.168.5.16 to my primary NIC (on the 192.168.8.x network).
The process for creating an IP alias is very similar to the steps outlined for the real interface in the previous section, "Changing Your IP Address":
- First ensure the parent real interface exists
- Verify that no other IP aliases with the same name exists with the name you plan to use. In this we want to create interface wlan0:0.
- Create the virtual interface with the ifconfig commandroot@pc016:~# ifconfig eth0:1 192.168.5.16 netmask 255.255.255.0 up