
External Links
A site for solving at least some of your technical problems...
A site for solving at least some of your technical problems...
Today I got a new IP address for a server and I had to assign it to the same NIC as my current IP address.
So?! How do you do that on a Debian or Ubuntu server?
It is actually very simple. On Ubuntu you go to /etc/network and edit the interfaces file. It should already include a definition for eth0 (virtual machines will have something else than eth0).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
auto eth0:0
iface eth0:0 inet static
name Alias for Foo
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
I marked in red what is different between both definitions.
Once you write that file to disk, you can start that interface with the ifup command:
ifup eth0:0
Now it is up and running (unless you got tons of errors?) Obviously, the eth0 interface is expected to already be up. You cannot start an alias if the main interface is not running.
To verify that the new interface is up and running, use the ifconfig command as in:
ifconfig
This command lists all the interfaces, including aliases. Note that aliases do not list the number of packets transfered since they are considered 100% similar to the main interface. This also applies to the firewall. In other words, you probably won't have to make any changes to your firewall...1
You can add more changing the number after the colon, for instance eth0:1, eth0:2, etc.
To be noted: You are limited to 254 aliases (0 to 254 + main interface, that's 255 IPs per NIC!)