I've got a CentOS system that I am trying to create a network bridge for KVM guests.
I have one Ethernet interface:
IPADDR: 101.X.X.20
GATEWAY: 101.X.X.1
I have secondary IPs:
72.X.X.31
72.X.X.32
72.X.X.33
72.X.X.34
I'm wanting to assign the KVM guest the 72.X.X.31 IP address. But I cannot get that to route.
I need to set the Host to recognize the 72.X.X.31 IP and forward that on to the KVM guest.
I then need the guest to be able to access the Internet through the 101.X.X.1 gateway.
How do I set up the bridge to accomplish this?
Posted by devops036, 02-19-2015, 08:23 PM
What you try to achieve is possible: I did it
What you need:
- the MAC address associated with each of your VM IP addresses (72.X.X.31, ...) (otherwise nothing will work, the host couldn't make the association),
- a configured bridge called br0 (change the name accordingly).
Follow these steps:
- stop your VM
- edit your VM configuration file (normally in the /etc/libvirt/qemu directory)
- search for
- replace with
- restart the libvirt daemon
service libvirtd restart
- start your VM
- connect to your VM through the console (virsh console vm)
- edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file
- assign the new MAC address to the HWADDR variable, the desired IP address
to the IPADDR variable, the desired gateway to the GATEWAY variable and the NETMASK 255.255.255.255 (or PREFIX=32) IMPORTANT!
If your VM is in CentOS 7, it should work straight.
If your VM is in CentOS 6, you've got an additional tricky step (don't ask me for CentOS 1 to 5, I didn't try and don't want to!).
You have to create a file called /etc/sysconfig/network-scripts/route-eth0 and paste the following lines with your default gateway:
101.X.X.1 dev eth0
default via 101.X.X.1 dev eth0
It worked for me, it should work for you: I've got no superpower!
Good luck!
Posted by SPaReK, 02-21-2015, 07:09 PM
I was able to get this figured out. My solution is below. The key part I seemed to be missing was the parts in the /etc/sysconfig/network-scripts/route files.
On the HOST:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-br0
/etc/sysconfig/network-scripts/route-br0
On the GUEST:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/route-eth0