I have an interface eth0
, and I wish to give it an extra virtual IP. I achieve this by the following:
ifconfig eth0:0 ip.address.goes.here netmask subnet.address.goes.here
This works fine, however, when I reboot, this is lost.
I have tried editing /etc/network/interfaces
to add the following:
auto eth0:0 iface eth0:0 inet static
address ip.address.goes.here
netmask subnet.address.goes.here
However, upon rebooting, the static ip for eth0 is loaded fine, but, the eth0:0 virtual IP is not loaded at all.
So, how can I permanently add the eth0:0
virtual IP?
Instead of that
eth0:0
business, you should do this:Configure your (one) static IP address in
/etc/network/interfaces
as you normally would:Add another IP to this interface by adding this right after the above:
The complete file should look like this
Now, if you check what IP addresses are configured by running
ip addr show
, both will show up:My thanks to Lekensteyn for pointing me in the right direction. Every site on the internet just talks about
eth0:0
for a secondary IP address. This seems like the proper way to do it.If you want to do things the "traditional" way, the relevant part of
/etc/network/interfaces
should look like:instead of this, where you made a mistake: