理解openstack中与虚拟机相关一些简单网络知识-2.veth pair

     

介绍

Virtual Ethernet Pair简称veth pair,是一个成对的端口,所有从这对端口一端进入的数据包都将从另一端出来,反之也是一样.

下面用例子说明vethpair的创建和使用:

现在有这样一个环境,两个网桥,一个是Linux内核网桥br1,另一个是ovs网桥 br-eth1,现在想把两个网桥连接起来,就可以用veth pair.

+------------------+              +------------------+
|                  |              |                  |
|   ovs bridge     |              |   Linux bridge   |
|   br-eth1        |              |   br1            |
|                  |              |                  |
+------------------+              +------------------+

首先创建一对vethpair:

# ip link add eth1-br1 type veth peer name phy-br1
# ip link list

...

25: phy-br1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 22:83:01:db:37:b4 brd ff:ff:ff:ff:ff:ff
26: eth1-br1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 32:b2:aa:1a:8a:13 brd ff:ff:ff:ff:ff:ff
创建成功后,可以通过ip link看到一对端口,可以通过ethtool查看他们是否成 对:
# ethtool -S phy-br1
NIC statistics:
     peer_ifindex: 26

创建成功后,就可以分别将两个端口添加到不同的网桥上:

linux网桥

# brctl addif br1 phy-br1
# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.e41f136dc9f0       no              enp11s0f0
                                                        vnet0
                                                        vnet2
                                                        vnet3
br1             8000.deef26d9c76a       no              phy-br1
                                                        vnet1
                                                        vnet4

可以看到phy-br1添加到了br1网桥上.

ovs网桥

# ovs-vsctl add-port br-eth1 eth1-br1
# ovs-vsctl show
e61b93e6-a701-4b6e-86c2-05f883885ab8
    Bridge br-int
        fail_mode: secure
        Port "qvof01b51bf-71"
            tag: 1
            Interface "qvof01b51bf-71"
        Port "int-br-eth1"
            Interface "int-br-eth1"
        Port br-int
            Interface br-int
                type: internal
    Bridge "br-eth1"
        Port "eth1-br1"
            Interface "eth1-br1"
        Port "eth1"
            Interface "eth1"
        Port "phy-br-eth1"
            Interface "phy-br-eth1"
        Port "br-eth1"
            Interface "br-eth1"
                type: internal
    ovs_version: "2.3.0"

可以看到eth1-br1也添加到了br-eth1网桥上了.这样整个网络就完成了网桥的连接:

+------------------+              +------------------+
|  ovs bridge      |              |   Linux bridge   |
|  br-eth1         |              |   br1            |
|       +----------+              +----------+       |
|       | eth1-br1 +--------------+ phy-br1  |       |
+-------+----------+              +----------+-------+

参考链接

http://blog.csdn.net/ztguang/article/details/56479154





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值