Multiple NICs with only one real NIC...


I've been searching for this all night long, so here it is.

I wanted to be able to have two network interfaces on my Debian Server. One is real, the actual NIC, the other has to be virtual then. An alias would not be suitable since I need to be able to use two gateways, and specify which eth* to use in a script.

My network configuration is a little bit complex, since I have two Internet access (two ADSL modems) on the same subnet, and I want to be able to cross-check the two Internet connexions (link1 tests link2 accessiblity, and link2 tests link1)

In the process, I managed to make my server unavailable... so don't do this when using an SSH session... don't mess with the network settings...

Well, the solution:

ip link add link eth0 address 00:11:22:33:44:55 eth1 type macvlan

Or in the /etc/network/interfaces file:

# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static

iface eth1 inet static
        pre-up ip link add link eth0 address 00:11:22:33:44:55 eth1 type macvlan
        post-down ip link del eth1


It seems I'm getting DUP! answers when I ping any IP on the network, so that's still an issue to be dealt with, but I'm happy to have found this "trick"...

Nevermind, this morning, I reconnected to the server and installed this "cloning", I don't get any dup... So it should come from my VBox debian.

Cia ;)


EDIT: Just occured to me, it's easier to force a route than setting all this stuff since it only concerns one external IP... Neverming, it was kinda fun ^^