多個router和多個network

通常搭建成功了opentack後,都會按照文檔的這樣建立網絡ubuntu

Scenario 1: one tenant, two networks, one router網絡

Scenario 2: two tenants, two networks, two routersoop

然而neutron號稱軟件定義網絡,能否建立更復雜的拓撲圖.net

 

image

我建立了上面的三個網絡,每一個網絡都運行一個主機,網絡1和網絡2,並不直接相連,可是經過網絡2相連。3d

對於主機net1,因爲網絡只有一個路由器,因此gateway只能是它router

root@net1:/home/ubuntu# ip addr blog

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN ip

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 路由

inet 127.0.0.1/8 scope host lo 文檔

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:f2:68:34 brd ff:ff:ff:ff:ff:ff

inet 10.0.0.2/24 brd 10.0.0.255 scope global eth0

inet6 fe80::f816:3eff:fef2:6834/64 scope link

valid_lft forever preferred_lft forever

root@net1:/home/ubuntu# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 10.0.0.1 0.0.0.0 UG 100 0 0 eth0

10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

對於主機net3,所在的網絡業只有一個路由器,因此gateway也只能是它

root@net3:/home/ubuntu# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:73:2b:1f brd ff:ff:ff:ff:ff:ff

inet 10.0.2.2/24 brd 10.0.2.255 scope global eth0

inet6 fe80::f816:3eff:fe73:2b1f/64 scope link

valid_lft forever preferred_lft forever

root@net3:/home/ubuntu# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 10.0.2.1 0.0.0.0 UG 100 0 0 eth0

10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

比較糾結的是主機net2,它的網絡上有兩個路由器,默認gateway只能是一個,那它如何才能ping通兩面的主機呢,必須手動添加路由器。

root@net2:/home/ubuntu# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:3c:65:ad brd ff:ff:ff:ff:ff:ff

inet 10.0.1.4/24 brd 10.0.1.255 scope global eth0

inet6 fe80::f816:3eff:fe3c:65ad/64 scope link

valid_lft forever preferred_lft forever

root@net2:/home/ubuntu# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 10.0.1.1 0.0.0.0 UG 100 0 0 eth0

10.0.0.0 10.0.1.1 255.255.255.0 UG 0 0 0 eth0

10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

10.0.2.0 10.0.1.2 255.255.255.0 UG 0 0 0 eth0

到不一樣的網絡,gateway不同。

最後的問題是,net1和net3之間怎麼通訊,若是neutron建立的路由器支持動態路由就行了,通常經過routed或者gated,相鄰的路由器router1和router2能夠相互同步路由表,這樣router1纔可能知道,在router2的另外一端,還有一個網絡,反之亦然。

https://blueprints.launchpad.net/neutron/+spec/bgp-dynamic-routing

然而這個好像還沒實現,因此要想net1和net3之間通訊,須要手動添加路由表到路由器

咱們修改router1的路由表

root@escto-bj-hp-z620:~# ip netns exec qrouter-8fd947fc-2b5b-40a3-b16e-72aabb001f2d route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 qr-bbbc67c3-81

10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 qr-10b0d153-4c

10.0.2.0 10.0.1.2 255.255.255.0 UG 0 0 0 qr-10b0d153-4c

再來修改router2的路由表

root@escto-bj-hp-z620:~# ip netns exec qrouter-d2c831c9-44ff-43dd-8c9d-2dc42370c2fd route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.0.0.0 10.0.1.1 255.255.255.0 UG 0 0 0 qr-ad73f294-6d

10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 qr-ad73f294-6d

10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 qr-866838bd-d7

這樣相互就ping通了

image

image

image

經過API建立路由表

https://blueprints.launchpad.net/neutron/+spec/quantum-l3-routes

相關文章
相關標籤/搜索