Adding Linux VLAN and bridge interfaces using libvirt
来源:互联网 发布:java log4j 日志级别 编辑:程序博客网 时间:2024/06/05 14:07
Always wanted to now how to add interfaces (VLANs or bridges) to your Linux hypervisor without dealing with the distribution specific network configuration to serve guest networks ?
Just use libvirt or its command line tool virsh to accomplish this tutorial.
First create a XML file containing your physical network layout. In this example I have a bonded Ethernet interface (bond0) and create a new Ethernet interface bond0.10 which tags the Ethernet traffic to VLAN ID 10. It is just a arbitrary number in this example but I always suggest to tag all VM guest traffic using a bridge. Ideally those bridges are running on top a bonding interface which is sometimes called teaming. Using the Linux bonding driver you can aggregate multiple interfaces to a logical interfaces which can enhance bandwidth. Your switch should support IEEE 802.3AD aggregation protocols like LACP otherwise I recommend to use active-passive bonding to enhance reliability against NIC or switch failures.
<interface type='bridge' name='br10'> <start mode='onboot'/> <bridge> <interface type='vlan' name='bond0.10'> <vlan tag='10'> <interface name='bond0'/> </vlan> </interface> </bridge> </interface>
Finally create your libvirt/Linux interface
sudo virsh iface-define br10.xml
sudo virsh iface-start br10
Now adding a libvirt network using this XML file. I just create a network called vlan10 and connect it to the previous created bridge.
<network connections='1'> <name>vlan10</name> <forward mode='bridge'/> <bridge name='br10' /></network>
Time to assemble your libvirt network.
sudo virsh net-define vlan10.xml
sudo virsh net-start vlan10
sudo virsh net-autostart vlan10
If everything is done right just check it using virsh again :
virsh # iface-listName State MAC Address--------------------------------------------bond0 active 00:1d:09:70:a5:a2br10 active 00:1d:09:70:a5:a2lo active 00:00:00:00:00:00virsh # net-listName State Autostart Persistent-------------------------------------------------default active yes yesvlan10 active yes yes
virsh # net-info vlan10Name vlan10UUID a19fa2be-161a-f7cc-a776-e645a990eee2Active: yesPersistent: yesAutostart: yesBridge: br10
For the RedHat or CentOS guys who want to know how bonding interfaces can be created, just add the file ifcfg-bond0 (the number must be incremented with every new interface)
DEVICE=bond0TYPE=EthernetBOOTPROTO=noneONBOOT=yesBONDING_OPTS="mode=1 miimon=100"
Finally assign multiple Ethernet interfaces, at least one for mode 1 (active-passive), to this bonding device by adding the following lines in each ifcfg-ethX file:
SLAVE="yes"MASTER="bond0"
http://www.teipel.ws/2013/06/06/adding-vlans-and-bridges-using-libvirt/
- Adding Linux VLAN and bridge interfaces using libvirt
- Adding Linux VLAN and bridge interfaces using libvirt
- linux bridge and vlan explained
- linux上bridge vlan etho
- tap interfaces disabled in linux bridge
- Using abstractions and interfaces with Unity3D
- Using VLANs with OVS and libvirt
- Using VLANs with OVS and libvirt
- Are You Using Abstract Classes, Polymorphism, and Interfaces? @ JDJ
- debian linux interfaces and resolv configuration
- Using Open vSwitch with libvirt and QEMU/KVM
- Using Interfaces in C++
- Using ReiserFS and Linux
- programming interfaces using raw socket
- COM Objects and Interfaces
- Interfaces and Scripting Objects
- VidPN Objects and Interfaces
- Interfaces and factories
- CF 登录界面制作
- 十分钟让你明白Objective-C的语法(和Java、C++的对比)
- 破解 找回 lockdir 加密的文件
- feof使用注意
- UVA 12587 Reduce the Maintenance Cost
- Adding Linux VLAN and bridge interfaces using libvirt
- ComboBox SelectionChanged改变SelectedItem MenuItem通过什么方法获得子元素选中项,已解决!
- MySQL EXPLAIN 命令详解学习
- 10277 Boastin' Red Socks(概率 暴力枚举)
- Hibernate快速入门教程(2)
- 【杂七杂八】大四的反思
- CSS 魔法系列:纯 CSS 绘制图形(心形、六边形等)
- 一个简单的http server
- mapreduce如何调用第三方jar包