Configuring Virtual Machines in same network as Host in RHEL 6.x /CentOS 6.x (Bonding and Bridging)

This post is written assuming that you already are running Virtual Machines using KVM on RHEL 6.x/CentOS 6.x.

Objective: To bring virtual machines, say vm01 and vm02 hosted on a Server, MyServer with two interfaces eth0 and eth1 on the same network as MyServer. Suppose MyServer's IP address is 10.x.y.a. I want my Virtual Machines to have IP addresses 10.x.y.b and 10.x.y.c. so that I will be able to access them from any machine from the same network as they are physcial machines. This way we will be able to access them over web if required.

How To:

First of all we need to do bonding of eth0 and eth1 of the MyServer so that they can be accessed through bond0 interface which is going to be connected to bridge br0 later.

# vi /etc/modprobe.d/bonding.conf

add below line in the newly created file:

alias bond0 bonding

# vi /etc/sysconfig/network

add below two lines:

NETWORKING=yes
HOSTNAME=MyServer

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Change your configuration as per below lines:

BOOTPROTO=none
DEVICE=eth0
HWADDR=<ENTERYOURETH0MACADDRESS>
MASTER=bond0
NM_CONTROLLED=no
ONBOOT=yes
SLAVE=yes
TYPE=Ethernet

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Change your configuration as per below lines:

BOOTPROTO=none
DEVICE=eth1
HWADDR=<ENTERYOURETH1MACADDRESS>
MASTER=bond0
NM_CONTROLLED=no
ONBOOT=yes
SLAVE=yes
TYPE=Ethernet

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Add below lines:

ARP=no
BONDING_OPTS="mode=1 miimon=100"
BOOTPROTO=static
BRIDGE=br0
DEVICE=bond0
NM_CONTROLLED=no
ONBOOT=yes

# vi /etc/sysconfig/network-scripts/ifcfg-br0

Add below lines:

BOOTPROTO=static
DEVICE=br0
GATEWAY=<MYSERVER_GATEWAY>
IPADDR=<MYSERVER_IP>
PREFIX=24
NM_CONTROLLED=no
ONBOOT=yes
SLAVE=bond0
TYPE=Bridge

#chkconfig NetworkManager off
#service NetworkManager stop
#service network restart

Now Shutdown your Virtual Machines, and Restart your Host Machine.

Start Virtual Machine Manager

Change Network Interface to use br0 bridge as shown in picture below:


Click apply and Start Virtual Machines.
Assign them Static IP addresses of same range as Host Machine network by making changes in their network configuration file (/etc/sysconfig/network-scripts/ifcfg-eth0). Restart network service and try pinging/ssh them from other hosts on same network. Good Luck.

References:
1. http://www.howtoforge.com/how-to-install-kvm-and-libvirt-on-centos-6.2-with-bridged-networking
2. https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-networkscripts-interfaces-chan.html
3. https://wikis.uit.tufts.edu/confluence/display/TUSKpub/Configure+Pair+Bonding+and+Bridges+for+KVM+Hypervisor

Comments

Popular posts from this blog

"gnome-screenshot" (No such file or directory)"

कुछ और

यादें