Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tosin2013/dd199b9ab45f00458e103566fef8f853 to your computer and use it in GitHub Desktop.
Save tosin2013/dd199b9ab45f00458e103566fef8f853 to your computer and use it in GitHub Desktop.
bridge and open vswitch network configuration.
###### Bridge network configuration.
# cat /etc/qemu-ifup
#!/bin/sh
switch=switch
/sbin/ifconfig $1 0.0.0.0 up
/usr/sbin/brctl addif ${switch} $1
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="none"
ONBOOT="yes"
HWADDR=08:2E:5F:0A:0D:B9
BRIDGE="switch"
# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="switch"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Bridge"
# chmod +x /etc/qemu-ifup
# service NetworkManager stop
# service network restart
###### Open vswitch network configuration.
Start the openvswitch service and chkconfig it up.
# yum install openvswitch -y
# systemctl start openvswitch.service|#service openvswitch start
# chkconfig openswitch on
Enable openvs.
# brctl show
# ifconfig switch down
# brctl delif switch eth0
# killall dhclient
# ovs-vsctl add-br ovs0
# ovs-vsctl add-port ovs0 eth0
# dhclient ovs0
rhel6# ifconfig switch down; brctl delif switch eth0; brctl delbr switch; service NetworkManager stop
rhel7# ifconfig switch down; brctl delif switch eth0; brctl delbr switch; systemctl disable NetworkManager.service
Setup guest network up/down script.
# cat /etc/ovs-ifup
#!/bin/sh
switch='ovs0'
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1
#cat /etc/ovs-ifdown
#!/bin/sh
switch='ovs0'
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1
Configure the network script.
# cat /etc/sysconfig/network-scripts/ifcfg-[$physdev] (eth0 in this case)
DEVICE=eth0
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSPort
OVS_BRIDGE=ovs0
# cat /etc/sysconfig/network-scripts/ifcfg-[ovsbridge] (ovs0 in this case)
DEVICE=ovs0
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=dhcp
OVSBOOTPROTO=dhcp
OVSDHCPINTERFACES=eth0 (open vswitch needs to specify which NIC are used when DHCPing)
stop and disable NetworkManger
# systemctl stop NetworkManger.service
# systemctl disable NetworkManger.service
start and enable openvswitch.service
# systemctl start openvswitch.service
# systemctl enable openvswitch.service
# systemctl restart network.service
qemu-kvm cmdline:
-netdev tap,id=tap_win,vhost=on,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown \
-device virtio-net-pci,netdev=tap_win,id=nic0,mac=1a:59:0a:4b:5a:94 \
# ovs-vsctl show
5c4e38c9-f83a-4515-9775-fc48e8f5f126
Bridge "ovs0"
Port "ovs0"
Interface "ovs0"
type: internal
Port "tap0"
Interface "tap0"
Port "eth0"
Interface "eth0"
ovs_version: "2.0.1"
# ovs-vsctl del-port tap0
openvswitch---->bridge:
1.stop the openvswitch service;
2.remove the openvswitch related package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment