I'm completely new to KVM and bridging and need your help. I have a remote server with QEMU/KVM and only SSH connection is available to me. Host OS is RHEL 7. Guests must be connected to bridge(ovs), they see each other and don't have access outside network. Host must be available to ping guests. Physical NIC interface mustn't be used because I can lose connection. So it's something like host see each virtual interface of guests and has access to them and guests see each other via bridge. I use libvirt trying to configure it following this instruction How to Use Open vSwitch with Libvirt. Help me, please.
First what I need is to create bridge:
sudo ovs-vsctl add-br ovsbr
Then I configure domain XML file using virsh like this:
<interface type='bridge'>
<mac address='52:54:00:71:b1:b6'/>
<source bridge='ovsbr'/>
<virtualport type='openvswitch'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
After restarting domain bridge has connected vnet0 interface which is interface of the guest. How addressing can be provided in this case? Can I give static address to guest via host?
Create network interface:
# cat /etc/sysconfig/network-scripts/ifcfg-br-int
DEVICE=br-int
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
HOTPLUG=no
IPADDR=10.17.0.1
NETMASK=255.255.255.0
Up interface:
# ifup br-int
It's create openvswitch bridge.
# ip -4 a show br-int
5: br-int: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
inet 10.17.0.1/24 brd 10.17.0.255 scope global br-int
valid_lft forever preferred_lft forever
Create a libvirt network:
# cat ovsnet.xml
<network>
<name>br-int</name>
<forward mode='bridge'/>
<bridge name='br-int'/>
<virtualport type='openvswitch'/>
</network>
define and start the network:
# virsh net-define ovsnet.xml
# virsh net-start br-int
# virsh net-autostart br-int
Create vm:
# qemu-img create -f qcow2 /opt/vm/test.qcow2 10G
# virt-install \
--ram 1024 \
--accelerate \
--disk path=/opt/vm/test.qcow2 \
--name test \
--network network:br-int \
--vcpus 1 \
--cpu core2duo \
--cdrom /opt/iso/CentOS-7.0-1406-x86_64-DVD.iso
Finish installation, logon to the new vm and configure network:
# cat /etc/sysconfig/network-scripts/ifcfg-ens3
DEVICE=ens3
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.17.0.2
NETMASK=255.255.255.0
GATEWAY=10.17.0.1
Up network interface:
# ifup ens3
Check ping from the host:
# ping 10.17.0.2 -c 1
PING 10.17.0.2 (10.17.0.2) 56(84) bytes of data.
64 bytes from 10.17.0.2: icmp_seq=1 ttl=64 time=0.398 ms
--- 10.17.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.398/0.398/0.398/0.000 ms
Current openvswitch configuration:
# ovs-vsctl show
73826453-249b-4558-9cf9-ad6cc169dec9
Bridge br-int
Port br-int
Interface br-int
type: internal
Port "vnet0"
Interface "vnet0"
ovs_version: "2.3.1-git4750c96"