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

1、openstack多租户实现IP逻辑资源复用示意图

实现隔离的方式是用network namespace 实现router 隔离。

如果没有router隔离,租户网络路由无法正常转发。

比如:

        租户A 192.186.10.100 访问 192.186.11.110,因为有router-ns1隔离,才能转发到ns02。且router namspace和租户相对应。

        假设没有 router-ns1 和 router-ns2,198.168.10.1和198.168.11.1直接暴露在host network,无法设置路由规则转发给正确的目的网口。

2、租户网络

租户A: 192.186.10.0/24 vlan 3; 192.186.11.0/24 vlan 4

租户B: 192.186.10.0/24 vlan 33; 192.186.11.0/24 vlan 44

3、创建租户B网络环境(租户A已经在文章一创建完成)

1)创建network namespace

ip netns add ns03

ip netns add ns04

ip netns add router-ns2

2)创建veth口

ip link add veth11 type veth peer name veth12

ip link add veth13 type veth peer name veth14

ip link add veth15 type veth peer name veth16

ip link add veth17 type veth peer name veth18

3)连接网桥和namespace

ip link set veth11 netns ns03

ip link set veth13 netns router-ns2

ip link set veth15 netns router-ns2

ip link set veth17 netns ns04

ovs-vsctl add-port br-int veth12

ovs-vsctl add-port br-int veth14

ovs-vsctl add-port br-int veth16

ovs-vsctl add-port br-int veth18

4)打开网口和配置地址

ifconfig veth12 up

ifconfig veth14 up

ifconfig veth16 up

ifconfig veth18 up

ip netns exec ns03 ifconfig  veth11 192.168.10.100/24 up

ip netns exec ns04 ifconfig  veth17 192.168.10.110/24 up

ip netns exec router-ns2 ifconfig  veth13 192.168.10.1/24 up

ip netns exec router-ns2 ifconfig  veth15 192.168.11.1/24 up

5)打开namespace路由转发功能

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

6)设置路由

ip netns exec ns04 route add -net 192.168.10.0/24 gw 192.168.11.1/24 dev veth17

ip netns exec ns03 route add -net 192.168.11.0/24 gw 192.168.10.1 dev veth11

4、实验结果图

1)ping 结果

 2)ns03路由

  3)ns04路由

 4)router-ns2路由

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值