# Start the xen service:
Xend start
# List virtual machines
XM list
# Start
XM create-c vm name
# Entering a virtual machine
XM console Virtual Machine name
# Exiting a VM
CTRL]
# Disable
XM Shutdown
Linux bridge implements the IEEE 802.1d protocol, which does not support VLAN functions. That is to say, this implementation can only carry one broadcast domain, but not multiple broadcast domains. Of course, you can create multiple bridge devices. Each bridge corresponds to a different VLAN. In the bridge, packets are forwarded through the FDB table, but this FDB table does not contain VLAN information. If you want to communicate between multiple bridge devices, you must create a VLAN interface on the bridge device and configure routes to implement forwarding between different bridges.
Linux VLAN implements the IEEE 802.1Q protocol. 802.1Q should have been a layer-2 protocol, but Linux needs to create a VLAN interface, and IP addresses can be configured on the VLAN interface. Therefore, this interface can be placed in the route table. In general, the packets received on this interface will carry the vlan id configured for this interface, and the packets sent from this interface will carry the vlan id of this interface.
1. Create two bridge and network card sub-interfaces
1. The two bridges are named xenbr2 and xenbr3.
2. Two Nic interfaces, eth1.10, run vlan10 and bridge to xenbr3; eth1.40, and VLAN 40, and xenbr2.
3. Run the command brctl addbr bridgename to add the bridge, brctl addif bridgename devicename to add the NIC to the bridge, or create a configuration file. The configuration file is recommended. The file location and content are as follows:
[Root @ localhost network-Scripts] # Cat/etc/sysconfig/network-scripts/ifcfg-xenbr2
Device = xenbr2
Bootproto = static
Onboot = Yes
Type = Bridge
[Root @ localhost network-Scripts] # Cat/etc/sysconfig/network-scripts/ifcfg-xenbr3
Device = xenbr3
Bootproto = static
Onboot = Yes
Type = Bridge
[Root @ localhost network-Scripts] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1.40
Device = eth1.40
Bootproto = none
Onboot = Yes
Type = Ethernet
VLAN = Yes
Bridge = xenbr2
[Root @ localhost network-Scripts] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1.10
Device = eth1.10
Bootproto = none
Onboot = Yes
Type = Ethernet
VLAN = Yes
Bridge = xenbr3
PS: After the NIC sub-interface is added to the bridge, it becomes a port of the bridge. The bridge is a layer-2 device, so the IP address configured for the NIC sub-interface is invalid. You can configure IP addresses on the bridge interface for management.
2. Start the bridge
IFUP xenbr2
IFUP xenbr2
IFUP eth1.10
IFUP eth1.40
PS: the sub-interface of the bridge and network card starts sequentially. You must first start the bridge and then start the sub-interface of the network card. Because the NIC is added to the bridge ~
3. Add NICs for virtual machines
[Root @ xen-centos ~] # Virsh
Virsh # attach-interface centos bridge xenbr2
This command can add a NIC bridge to xenbr2.
The command to delete the NIC. The first Nic is deleted by default without Mac.
Virsh # detach-interface centos bridge -- Mac 00: 16: 3E: 24: B5: 3B
PS: The NIC will not be lost after restart. After the configuration file is reloaded after shutdown, the NIC will be lost. The following describes how to modify the configuration file.
Modify the configuration file of the xen Virtual Machine
The configuration file is in/etc/xen, and the corresponding item in the configuration file is VIF
1. the VM only uses one network card
[Root @ localhost xen] # Cat/etc/xen/centos
Name = "centos"
UUID = "eb2f58c6-cd95-8109-f29e-5df80df8c476"
Maxmem = 256
Memory = 256
Vcpus = 1
Bootloader = "/usr/bin/pygrub"
On_poweroff = "Destroy"
On_reboot = "restart"
On_crash = "restart"
Disk = ["tap: AIO:/virtual/centos/centos5.5.img, xvda, W"]
VIF = ["Mac = 00: 16: 36: 2b: 3f: A1, bridge = xenbr3, script = VIF-bridge"]
2. The virtual machine uses two NICs
[Root @ localhost xen] # Cat/etc/xen/centos
Name = "centos"
UUID = "eb2f58c6-cd95-8109-f29e-5df80df8c476"
Maxmem = 256
Memory = 256
Vcpus = 1
Bootloader = "/usr/bin/pygrub"
On_poweroff = "Destroy"
On_reboot = "restart"
On_crash = "restart"
Disk = ["tap: AIO:/virtual/centos/centos5.5.img, xvda, W"]
VIF = ["Mac = 00: 16: 36: 2b: 3f: A1, bridge = xenbr3, script = VIF-bridge", "Mac = 00: 16: 36: 2b: 3f: A2, bridge = xenbr2, script = VIF-bridge "]
Iv. Last step
Change the port mode of the vswitch to trnuk.
Summary: in this way, you can add multiple VLANs to create a VLAN that is not used for Nic sub-interfaces. If you have multiple NICs, you can connect them to different NICs. Flexible networking. You can also use the bonding technology to bridge the physical Nic. This technology is good, haha ~
Bridges have the following features:
(1) Work in hybrid mode.
(2) There is an address table that maps globally unique addresses to bridge ports.
(3) The forwarding is determined based on the destination address of the received frame.
(4) create and update an address table based on the source address of the received frame.
(5) When an unknown destination address is encountered, the frame is forwarded to each port (except the port that receives the frame ).
In this way, the network in our IDC officially supports multiple VLANs. Currently, 8 VLANs are supported.
IP addresses are distributed in 9 CIDR blocks: 192.168.0. *-192.168.8 .*
Data Center 1: vlan8
Data Center 2: vlan2
Data Center 3: vlan3, VLAN4, vlan5, vlan6, and vlan7.
The vconfig tool is used.
IP addres add 0.0.0.0 Dev eth2
Enable eth2 to support 7 VLANs in 3 IDCs: vlan2-vlan8
Vconfig add eth2 2
Vconfig
Add eth2 3
Vconfig add eth3 4
Vconfig add eth2 5
Vconfig add eth2 6
Vconfig add eth2 7
Vconfig add eth2 8
Eth0 follows the vro and goes through the Internet
Eth1 connects to the default vlan1, other Intranet servers, and network management workstations.
The physical network card eth2 is broken into seven virtual network cards: eth2.2, eth2.3, eth2.4, eth2.5, eth2.6, eth2.7, eth2.8.
Set IP addresses for the seven virtual NICs respectively.
Ifconfig eth0.100 100.100.100.100 netmask 255.255.255.0 up
Ifconfig eth0.100 100.101.100.101 netmask 255.255.255.0 up
Finally, configure static routes for seven VLANs:
IP
Route add 192.168.2.0/24 Dev eth2.2
IP Route add 192.168.3.0/24 Dev
Eth2.3
IP Route add 192.168.4.0/24 Dev eth2.4
IP Route add
192.168.5.0/24 Dev eth2.5
IP Route add 192.168.6.0/24 Dev eth2.6
IP
Route add 192.168.7.0/24 Dev eth2.7
IP Route add 192.168.8.0/24 Dev
Eth2.8
Linux VLAN-to-Cisco switch relay connection: http://www.net527.com/caozuoxitong/Linux/1119.htmlhttp://www.net527.com/caozuoxitong/Linux/1119.html
Linux single Nic and 8 VLAN communication http://hi.baidu.com/zouhaoo/blog/item/3a85402acb061021d42af18d.html
LINUX multi-IP, multi-VLAN http://kb.cnblogs.com/a/2205770/