ovs+namespace实现跨网络通信(1)

1、环境准备

完成ovs安装

        参考:      Ubuntu 16.04 源码安装 openVswitch 2.10.0_品学楼A107-CSDN博客_ubuntu 安装openvswitch

2、准备环境结构图

        

3、创建网桥br-int 和 namespace

ovs-vsctl add-br br-int

ip netns add ns01
ip netns add ns02 

ip netns add router-ns1

4、创建veth对口,连接网桥和namespace

1)创建veth口
ip link add veth01 type veth peer name veth02

ip link add veth03 type veth peer name veth04

ip link add veth05 type veth peer name veth06

ip link add veth07 type veth peer name veth08

2)连接namespace

ip link set veth01 netns ns01

ip link set veth03 netns router-ns1

ip link set veth05 netns router-ns1

ip link set veth07 netns ns02

3)连接网桥并启用端口

ovs-vsctl add-port br-int veth02

ifconfig veth02 up

ovs-vsctl add-port br-int veth04

ifconfig veth04 up

ovs-vsctl add-port br-int veth06

ifconfig veth06 up

5、配置namespace里的端口地址

ip netns exec ns01 ifconfig  veth01 192.168.10.100/24 up

ip netns exec router-ns1 ifconfig  veth03 192.168.10.1/24 up

ip netns exec router-ns1 ifconfig  veth05 192.168.11.1/24 up

ip netns exec ns02 ifconfig veth07 192.168.11.110/24 up

6、配置router转发

ip netns exec router-ns1  sysctl -w net.ipv4.ip_forward=1

7、设置br-int网桥内部vlan隔离

ovs-vsctl set Port veth02 tag=3

ovs-vsctl set Port veth04 tag=3

ovs-vsctl set Port veth06 tag=4

ovs-vsctl set Port veth08 tag=4

8、结果

1)ping结果

 2)网桥信息

tag:access口,内部的vlan值,同一vlan的网口数据进行转发

3) router信息

 通过直连路由转发

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值