博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
openstack中虚拟机怎么与物理机通信
阅读量:4229 次
发布时间:2019-05-26

本文共 2243 字,大约阅读时间需要 7 分钟。

How-to-connection-ns-outside

环境配置

网络接口

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

重启网络服务

service network restart

创建一个network namespace foo

ip netns add foo

查看network namespace

ip netns

创建一个vethp

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

将tap-foo分配到foo namespace中

ip link set tap-foo  netns foo

为tap-foo 添加一个ip地址

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

查看foo 空间中的网卡信息

ip netns exec foo ip a

为root namespace 中的tap-root添加ip

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

查看 root 空间中的网卡信息

ip a

检查是否网络连通

ping 192.168.10.2 ip netns exec foo ping 192.168.10.1

安装需要用到的包

yum install libvirt openvswitch python-virtinst xauth tigervnc -y

移除默认的libvirt 网络,方便清晰分析网络情况

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

启动openvswitch

service openvswitch startchkconfig openvswitch on

创建一个openvswitch bridge 名字叫br-int

ovs-vsctl add-br br-int

利用openvswitch 的 br-int,定义一个libvirt 网络

vi libvirt-vlans.xml
ovs-network

启动libvirt 网络

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

创建一个instance,并连接到ovs-network,网络接口部分配置如下

可以参考附件instance1.xml创建

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

启动console 以后,登录添加ip得知 192.168.1.20

ip addr add 192.168.1.20/24 dev eth0

添加一个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

转载地址:http://dznqi.baihongyu.com/

你可能感兴趣的文章
The Definitive Guide to the .NET Compact Framework
查看>>
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
查看>>
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
查看>>
Access VBA Programming
查看>>
Data Entry and Validation with C# and VB. NET Windows Forms
查看>>
C++ Network Programming, Volume 2: Systematic Reuse with ACE and Frameworks
查看>>
Java 6 Platform Revealed
查看>>
Beginning ASP.NET 2.0 Databases: From Novice to Professional
查看>>
Microsoft Windows 2000 Scripting Guide
查看>>
Visual Basic .NET Bible
查看>>
The Struts Framework: Practical Guide for Java Programmers
查看>>
C#.net Web Developer's Guide
查看>>
Virtualization with VMware ESX Server
查看>>
System Architecture with XML
查看>>
Microsoft SQL Server 2005 Stored Procedure Programming in T-SQL & .NET
查看>>
Sams Teach Yourself Microsoft Office Access 2003 in 24 Hours
查看>>
Leveraging Web Services: Planning, Building, and Integration for Maximum Impact
查看>>
Implementing Backup and Recovery: The Readiness Guide for the Enterprise
查看>>
Wireless Communications over MIMO Channels: Applications to CDMA and Multiple Antenna Systems
查看>>
UMTS Performance Measurement: A Practical Guide to KPIs for the UTRAN Environment
查看>>