| Dieser Inhalt in deutsch |

Debian - one network card - two ip-addresses

Problem

In a Computer with Debian only one network card (eth0) is installed. The system will get a second ip address without installing a second network card. The second ip address will still be present after a reboot. It is also possible to assing a second ip address at the terminal so no reboot ist required.

Maybe you need this at a proxy server who usually has two ip addresses.

Solution

/etc/network/interfaces

In /etc/network/interfaces add this in a way, that it matches with your requirements.

up ifconfig eth0:0 192.168.2.12 netmask 255.255.255.0 up
down ifconfig eth0:0 192.168.2.12 netmask 255.255.255.0 down

With these entries, the system is assigned a new IP at startup.

Manually assign the IP address on the fly; gets lost when you restart the computer:

# ifconfig eth0:0 192.168.2.12 netmask 255.255.255.0 up

In a test it has even worked to assign a third IP address to a different subnet.