How virtual machines in OpenStack communicate with physical machines

Source: Internet
Author: User
Tags openvswitch

How-to-connection-ns-outsideEnvironment configuration

Network interface

vi/etc/sysconfig/network-scripts/ifcfg-eth0device=eth0type=ethernetonboot=yesnm_ controlled=yesbootproto=staticipaddr=10.20.0.10netmask=255.255.255.0vi/etc/sysconfig/network-scripts/ ifcfg-eth1device=eth1type=ethernetonboot=yesnm_controlled=yesbootproto=staticipaddr=172.16.0.10netmask= 255.255.255.0vi/etc/sysconfig/network-scripts/ifcfg-eth2device=eth2type=ethernetonboot=yesnm_controlled= yesbootproto=staticipaddr=192.168.4.10netmask=255.255.255.0  

Restart Network Service

service network restart

Create a network namespace foo

ip netns add foo

View Network namespace

ip netns

Create a VETHP

ip link add tap-foo type veth peer name tap-root

assigning Tap-foo to Foo namespace

ip link set tap-foo  netns foo

Add an IP address for Tap-foo

ip netns exec foo ip addr add 192.168.10.2/24 dev tap-foo ip netns exec foo ip link set tap-foo up

View NIC information in Foo space

ip netns exec foo ip a

Add IP to Tap-root in root namespace

 ip addr add 192.168.10.1/24 dev tap-root ip netns exec foo ip link set tap-root up

View network card information in the root space

ip a

Check if network connectivity

 ping 192.168.10.2 ip netns exec foo ping 192.168.10.1


Install the package that needs to be used

yum install libvirt openvswitch python-virtinst xauth tigervnc -y

Remove the default Libvirt network for easy and clear analysis of network conditions

virsh net-destroy defaultvirsh net-autostart --disable defaultvirsh net-undefine default

Start Openvswitch

service openvswitch startchkconfig openvswitch on

Create a openvswitch bridge called Br-int

ovs-vsctl add-br br-int

Use Openvswitch's br-int to define a libvirt network

vi libvirt-vlans.xml<network> <name>ovs-network</name> <forward mode= ' Bridge '/> <bridge name= ' br-int '/> <virtualport type= ' openvswitch '/> <portgroup name= ' No-vlan ' default= ' yes ' > </portgroup> <portgroup name= ' vlan-100 ' > <vlan> <tag id= ' + '/> < ;/vlan> </portgroup> <portgroup name= ' vlan-200 ' > <vlan> <tag id= ' $ '/> </vlan&  Gt </portgroup></network>  

Start Libvirt Network

virsh net-define libvirt-vlans.xmlvirsh net-autostart ovs-networkvirsh net-start ovs-network

Create a instance, and connect to the Ovs-network, the Network Interface section is configured as follows

<interface type=‘network‘>  <source network=‘ovs-network‘ portgroup=‘vlan-100‘/>  <model type=‘virtio‘/></interface>

You can refer to attachment instance1.xml to create

cp ~/gre/ /var/tmp/cd /var/tmp/gremv cirros-0.3.0-x86_64-disk.img instance1.imgvirsh define instance1.xmlvirsh start instance1virsh vncdesplay instance1vncviewer :0

After you start the console, login to add IP to know 192.168.1.20

ip addr add 192.168.1.20/24 dev eth0

Add a Openvswitch port

ip link add br-int-tap100 type veth peer name tap100ovs-vsctl add-port br-int br-int-tap100ovs-vsctl set port br-int-tap100 tag=100ip addr add 192.168.1.21/24 dev tap100ip link set tap100 upip link set br-int-tap100 up

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

How virtual machines in OpenStack communicate with physical machines

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.