Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a host running virtual machines using KVM. Each additional IP I get from the hosting company is bound to a specific virtual MAC address and will only work with this MAC (their router configuration).

I got vmbr0 which is a eth0 bridge. Now I need to give one VM two IPs which are bound to two different MACs. The only way I can think of is to give the VM two network devices (eth0 and eth1) which different MACs. The problem is that they use the same network.

Here /etc/network/interfaces configuration (111.111.111.x and b:e:e:f:: are placeholders and a 255.255.255.255 netmask is required by my ISP)

auto eth0
iface eth0 inet static
        address 111.111.111.36
        broadcast 111.111.111.63
        netmask 255.255.255.255
        pointopoint 111.111.111.1
        gateway 111.111.111.1
iface eth0 inet6 static
        address b:ee:f:301::2
        netmask 64
        up ip -6 route add b:ee:f:300::1 dev eth0
        down ip -6 route del b:ee:f:300::1 dev eth0
        up ip -6 route add default via b:ee:f:300::1 dev eth0
        down ip -6 route del default via b:ee:f:300::1 dev eth0

auto eth1
iface eth1 inet static
        address 111.111.111.43
        broadcast 111.111.111.63
        netmask 255.255.255.255
        pointopoint 111.111.111.1
        gateway 111.111.111.1
iface eth1 inet6 static
        address b:ee:f:301:30::2
        netmask 64
        up ip -6 route add b:ee:f:300::1 dev eth1
        down ip -6 route del b:ee:f:300::1 dev eth1
        up ip -6 route add default via b:ee:f:300::1 dev eth1
        down ip -6 route del default via b:ee:f:300::1 dev eth1

However with this setup the network doesn't work and when I remove the gateway part from eth1 I get these messages in syslog (and the second IP does not work):

Apr 14 13:50:36 VM kernel: [  907.043036] martian source 111.111.111.43 from some.ip, on dev eth1
Apr 14 13:50:36 VM kernel: [  907.043084] ll header: 00:50:56:00:04:98:00:26:88:76:18:18:08:00

Is there any way to get this working? After some research I found out that you can't use two network interfaces on the same network segment. But I need to find a way to set 2 IP addresses (preferable using two network devices for easier firewalling).

share|improve this question

1 Answer 1

I am using 3 IPs for my box, but with virtual interfaces as shown below. Don't know if that is appropriate for your case...

auto eth0 eth0:1
iface eth0 inet static
        metric 100
        address 111.111.111.36
        broadcast 111.111.111.63
        netmask 255.255.255.255
        pointopoint 111.111.111.1
        gateway 111.111.111.1
        hwaddress ether 11:11:11:11:11:11     //updated

iface eth0 inet6 static
        address b:ee:f:301::2
        netmask 64
        up ip -6 route add b:ee:f:300::1 dev eth0
        down ip -6 route del b:ee:f:300::1 dev eth0
        up ip -6 route add default via b:ee:f:300::1 dev eth0
        down ip -6 route del default via b:ee:f:300::1 dev eth0

iface eth0:1 inet static
        metric 200
        address 111.111.111.43
        broadcast 111.111.111.63
        netmask 255.255.255.255
        pointopoint 111.111.111.1
        gateway 111.111.111.1
        hwaddress ether 22:22:22:22:22:22   //updated

iface eth0:1 inet6 static
        address b:ee:f:301:30::2
        netmask 64
        up ip -6 route add b:ee:f:300::1 dev eth1
        down ip -6 route del b:ee:f:300::1 dev eth1
        up ip -6 route add default via b:ee:f:300::1 dev eth1
        down ip -6 route del default via b:ee:f:300::1 dev eth1
share|improve this answer
    
This uses the eth0 interface for both IPs. In order to use two different MAC addresses I need two interfaces. Adding IPs is not the problem but the datacenter's routers only route the traffic to devices with the corrent mac setup. –  Eliasdx Apr 14 '11 at 12:27
    
@Eliasdx what if you add hwaddress ether 11:11:11:11:11:11 and hwaddress ether 22:22:22:22:22:22? –  alexm Apr 14 '11 at 17:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.