0

I have a set of public IPs for virtual machines. Each unique public IP is to be assigned to a unique guest. With bridged networking I share eth0 with KVM machines.

The ifcfg-eth0 file has configuration:

DEVICE=eth0
ONBOOT=yes
BRIDGE=br0
HWADDR=b8:ac:6f:65:31:e5
DNS1=8.8.8.8
TYPE=Ethernet

The ifcfg-br0 file has configuration:

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=121.33.7.1
GATEWAY=121.33.7.0
NETMASK=255.255.255.0
DELAY=0
DNS1=8.8.8.8

I use the default libvirt network file, a bridge summary returns

bridge name   bridge id         STP enabled interfaces
br0           8000.705240103540 no          eth0
                                            virtual-machine-0
                                            virtual-machine-1
                                            virtual-machine-2
                                            virtual-machine-3

It works fine for guest with both incoming connections and outgoing connections. But the problem with the configuration is that if a guest changes his network file in vm with another availabe public ip, he would be able to obtain the ip that isn't originally assigned to his vm. How to assign a particular public ip to a guest network interface?

  • 1
    Switch port security? 802.1x? The fact that these are virtual machines doesn't matter that much. – Michael Hampton Jan 29 '14 at 23:54
  • Assign the IPs from a DHCP server? Don't configure the IPs in the guests at all? – Zoredache Jan 30 '14 at 0:24
  • No, a vm guest in my host must have a static public ip that never changes. – Purres Jan 30 '14 at 1:10
1

Just found the right way to do it. Add a etables reule so that the vm guest that has interface virtual-machine-0 can use ip 121.33.7.5 only.

ebtables -A FORWARD -i virtual-machine-0 -p IPv4 --ip-src ! 121.33.7.5 -j DROP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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