Adverts

How to Alias An Interface

Once you have you an interface set up and running it is easy to set up an aliased interface that binds a second IP address to that interface. To set up an alias interface add a simplified iface stanza to the /etc/network/interfaces file. Note the use of a colon : and then a number to indicate the sub-interafce. Only the address and netmask need to be added to the sub-interface stanza. The example below sets up an alias interface with the address 123.123.123.123.

auto eth0:1
iface eth0:1 inet static
       address 123.123.123.123
       netmask 255.255.255.0

Once you have definded the alias interface you then bring it up as you would any other interface with "ifup eth0:1".

Side Note

As a side note. If you enter a stanza like this:

#INTENTIONALLY BROKEN DO NOT USE
auto eth0:1
iface eth1:1 inet static
       address 123.123.123.123
       netmask 255.255.255.0

When you try and bring up the interface you get an error message along the lines of "ifup unknown interface eth1:1=eth1:1". Took me two or three attempts at bring up the interface before I properly read the error message and fixed the problem.

Why Bind Multiple IP Addresses To One Interface

Some people bind multiple addresses to one interface so that it appears that different domians go to different machines. Normally this is performed using Apache virtual hosts but using seperate IP addresses can make moving domains about easier. AFIAK if more than one domain on a machine wants to use HTTPS then the only way to achieve this is to use bind multiple IP addresses to one interface (but don't quote me on that).

In my case this multiple address binding is a temporary measure so that I can configure a new server. I have given the new server a spot on the internal network with an internal IP address. I will use the firewall on the current server to send some requests through to the new server (I'm configuring the new server from work). When the new server is ready to go live I will simply connect it directly to the router, assign it the external IP address and turn off the firewall forwarding on the old server. It's a tricky set up but it means that I can transfer over the server a bit at a time.

Adverts

Donate and Help

Please support this site and
Bandwidth doesn't grow on trees y' know :o)

Adverts

Get Adsense