Summary
Openvswitch Virtual Switch centos6.x compiled installation and simple VLAN configuration
First, build a compilation environment
Install the compilation environment
#yum install gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake Rpm-bui LD Redhat-rpm-config Libtool
compiling RPM is recommended for normal users
Download Create compiled directory script
$wget Ftp://ftp.owlriver.com/pub/local/COLUG//RPM-build-tree.txt
Execute script
$sh Rpm-build-tree.txt
The following directory will be created in the current user home directory
Rpmbuild├──build├──buildroot├──rpms├──sources├──specs└──srpms
second, compile openvswitch rpm Package
# #切换至家目录 $CD ~# #下载openvswitch源码包 $wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz $CP openvswitch-2.3.1.tar.gz rpmbuild/sources/$tar xvf openvswitch-2.3.1.tar.gz$cd openvswitch-2.3.1# #编译内核 $cp rhel/ Openvswitch-kmod.files ~/rpmbuild/sources/$rpmbuild-bb rhel/openvswitch-kmod-rhel6.spec # #编译openvswitch rpm$ RPMBUILD-BB Rhel/openvswitch.spec
After compilation, the RPM package is located in
ll ~/rpmbuild/rpms/x86_64/total 11440-rw-rw-r--. 1 Firxiao firxiao 1223288 Dec 05:50 kmod-openvswitch-2.3.1-1.el6.x86_64.rpm-rw-rw-r--. 1 Firxiao firxiao 2640440 Dec 06:01 openvswitch-2.3.1-1.x86_64.rpm-rw-rw-r--. 1 Firxiao firxiao 7846548 Dec 06:01 openvswitch-debuginfo-2.3.1-1.x86_64.rpm
Upload openvswitch-2.3.1-1.x86_64.rpm kmod-openvswitch-2.3.1-1.el6.x86_64.rpm to VM1, vm2
Installing with Yum
#yum Install openvswitch-2.3.1-1.x86_64.rpm kmod-openvswitch-2.3.1-1.el6.x86_64.rpm
Start the service
#/etc/init.d/openvswitch start
third, configuration and use
vm1 vm2 vm1 and vm2 Create Bridge Adapter ovsbridge0 ---- ---- Create vlan100 network card based on OVSBRIDGE0. eth0 ech0-------------- -------------ovsbridge0 ovsbridge0 172.16.0.20/24 172.16.0.21/24-------------- --------------vlan100 vlan100192.168.100.2/24 192.168.100.3/24 ---------------- ------------ ----
Placing the configuration file on /etc/sysconfig/network-scripts
vm1 NIC configuration information
[email protected] network-scripts]# cat Ifcfg-eth0 device=eth0onboot=yesdevicetype=ovstype=ovsportovs_bridge= ovsbridge0bootproto=nonehotplug=no [[email protected] network-scripts]# cat Ifcfg-ovsbridge0 device=ovsbridge0onboot =yesdevicetype=ovstype=ovsbridgebootproto=staticipaddr=172.16.0.20netmask=255.255.255.0hotplug=no [[Email Protected] network-scripts]# cat ifcfg-vlan100 device=vlan100onboot=yesdevicetype=ovstype=ovsintportbootproto= staticipaddr=192.168.100.2netmask=255.255.255.0ovs_bridge=ovsbridge0ovs_options= "tag=100" OVS_EXTRA= "set Interface $DEVICE external-ids:iface-id=$ (hostname-s)-$DEVICE-vif "Hotplug=no
[[email protected] ~]# ovs-vsctl show fedbda2f-2516-4aff-b89f-ca221873eb9c bridge "Ovsbridge0" Port "vlan100" tag: 100 Interface " Vlan100 " type: internal Port "Eth0" Interface "Eth0" Port "Ovsbridge0" interface "OVSBRIDGE0" type: internal ovs_version: "2.3.1"
vm2 NIC configuration information
[[email protected] network-scripts]# cat ifcfg-eth0 device=eth0onboot=yesdevicetype=ovstype=ovsportovs_bridge=ovsbridge0bootproto= Nonehotplug=no [[email protected] network-scripts]# cat ifcfg-ovsbridge0 device= Ovsbridge0onboot=yesdevicetype=ovstype=ovsbridgebootproto=staticipaddr=172.16.0.21netmask=255.255.255.0hotplug =no [[email protected] network-scripts]# cat ifcfg-vlan100 device=vlan100onboot=yesdevicetype=ovstype=ovsintportbootproto=staticipaddr=192.168.100.3netmask= 255.255.255.0ovs_bridge=ovsbridge0ovs_options= "tag=100" ovs_extra= "set interface $DEVICE external-ids:iface-id=$ (hostname -s)-$DEVICE-vif "Hotplug=no
[[email protected] ~]# ovs-vsctl show646f5f0f-6a6b-4b01-9c3c-f7684aa64ecc Bridge "Ovsbridge0" Port "eth0" Interface "Eth0" Port "Ovsbridge0" Interface "Ovsbridge0" type: internal port "vlan100" tag: 100 Interface "vlan100" type: internal ovs_version: "2.3.1"
after configuring the NIC
#service Network Restart
iv. Test Configuration
Use 172.16.0.0/24 on VM2 on VM1 to communicate with each other
Communication with vlan100 192.168.100.0/24 is also possible two networks are isolated from one another
Compile RPM Reference: openvswitch-2.3.1/install. RHEL
Network configuration reference: Http://git.openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=rhel/README. Rhel;hb=head
This article from "Nicol Lock Silk Sorrow" blog, please make sure to keep this source http://smoke520.blog.51cto.com/9256117/1793069
Openvswitch CENTOS6. X Installation and use