[root@controller ~]# ip netns
qrouter-aa791a83-c11c-4bef-b454-b1c53502e323
[root@compute /]# ip netns
qrouter-aa791a83-c11c-4bef-b454-b1c53502e323
其中,网络节点由于agent工作在dvr_snat模式下,因此还有一个snatxxx 命名空间,xxx为路由ID;由于有两个租户网络,因此出现了两个qdhcpxxx命名空间,xxx为网络ID。
现在才看compute上的qrouter:
ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
18: qr-52218be2-97: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:b2:50:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global qr-52218be2-97
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feb2:509a/64 scope link
valid_lft forever preferred_lft forever
20: qr-3aeb9186-67: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:32:c5:eb brd ff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global qr-3aeb9186-67
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe32:c5eb/64 scope link
valid_lft forever preferred_lft forever
出现了两个qr设备,设备IP均为对应两个私有网络的gateway IP,然后才看此路由的rule:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip rule
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
3232235777: from 192.168.1.1/24 lookup 3232235777
3232236033: from 192.168.2.1/24 lookup 3232236033
才看对应路由table:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip route list table 3232235777
default via 192.168.1.7 dev qr-52218be2-97
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip route list table 3232236033
default via 192.168.2.3 dev qr-3aeb9186-67
通过qrouter的rule可以发现,来自from 192.168.1.1/24即192.168.1.0/24网络的包将会通过路由端口qr-52218be2-97 转发到ip地址为192.168.1.7 端口设备去,
来自from 192.168.2.1/24即192.168.2.0/24网络的包将会通过路由端口qr-52218be2-97 转发到ip地址为192.168.2.3 端口设备去。那么192.168.1.7和192.168.2.3在什么设备上呢?
我们来看网络节点的网络命名空间:
[root@network ~]# ip netns exec snat-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
11: sg-416d8a05-df: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:18:4a:21 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.3/24 brd 192.168.2.255 scope global sg-416d8a05-df
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe18:4a21/64 scope link
valid_lft forever preferred_lft forever
13: sg-f3407fd3-81: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:28:98:7d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.7/24 brd 192.168.1.255 scope global sg-f3407fd3-81
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe28:987d/64 scope link
valid_lft forever preferred_lft forever
14: qg-1b3cd60f-f5: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:c7:2a:6a brd ff:ff:ff:ff:ff:ff
inet 192.168.115.156/24 brd 192.168.115.255 scope global qg-1b3cd60f-f5
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fec7:2a6a/64 scope link
valid_lft forever preferred_lft forever
可以看到:192.168.1.7和192.168.2.3出现在network节点上的snat命名空间里面,对应的端口设备是sg-f3407fd3-81和sg-416d8a05-df,而此snat命名空间连接外网的端口是qg-1b3cd60f-f5,
对应的外网固定IP是192.168.115.156,此ip是在neutron router-gateway-set demo-router ext-net命令设置的,此IP 可以通过命令查看:
[root@controller ~]# neutron router-list
+--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| id | name | external_gateway_info | distributed | ha |
+--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| aa791a83-c11c-4bef-b454-b1c53502e323 | demo-router | {"network_id": "282bbb70-6903-4d3d-84ea-c2c8349ff11b", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "ac8b9f0a-0309-495a-98d6-325017a5d8b2", "ip_address": "192.168.115.156"}]} | True | False |
+--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
查看snat命名空间的转发规则:
valid_lft forever preferred_lft forever
[root@network ~]# ip netns exec snat-aa791a83-c11c-4bef-b454-b1c53502e323 iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N neutron-l3-agent-OUTPUT
-N neutron-l3-agent-POSTROUTING
-N neutron-l3-agent-PREROUTING
-N neutron-l3-agent-float-snat
-N neutron-l3-agent-snat
-N neutron-postrouting-bottom
-A PREROUTING -j neutron-l3-agent-PREROUTING
-A OUTPUT -j neutron-l3-agent-OUTPUT
-A POSTROUTING -j neutron-l3-agent-POSTROUTING
-A POSTROUTING -j neutron-postrouting-bottom
-A neutron-l3-agent-POSTROUTING ! -i qg-1b3cd60f-f5 ! -o qg-1b3cd60f-f5 -m conntrack ! --ctstate DNAT -j ACCEPT
-A neutron-l3-agent-snat -o qg-1b3cd60f-f5 -j SNAT --to-source 192.168.115.156
-A neutron-l3-agent-snat -m mark ! --mark 0x2 -m conntrack --ctstate DNAT -j SNAT --to-source 192.168.115.156
-A neutron-postrouting-bottom -m comment --comment "Perform source NAT on outgoing traffic." -j neutron-l3-agent-snat
在DVR部署下,租户不同网络之间的VM数据流是如何走向的,即VM之间的东西流向分析如下:
在DVR情况下,每一个compute上都有一个和network节点上一模一样的router,假如租户的两个网络同事接入一个router里面,那么这个router必然有两个内部网络接口,命令查看如下(每个node都一样):
You have new mail in /var/spool/mail/root
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
18: qr-52218be2-97: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:b2:50:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global qr-52218be2-97
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feb2:509a/64 scope link
valid_lft forever preferred_lft forever
20: qr-3aeb9186-67: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:32:c5:eb brd ff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global qr-3aeb9186-67
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe32:c5eb/64 scope link
valid_lft forever preferred_lft forever
即路由上有两个qr接口,ip分别为两个私网的gateway IP,查看此qrouter上的路由:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip route
192.168.1.0/24 dev qr-52218be2-97 proto kernel scope link src 192.168.1.1
192.168.2.0/24 dev qr-3aeb9186-67 proto kernel scope link src 192.168.2.1
##########################################DVR 配置有floating-ip分析###############################################################################
在以上分析的基础上,为VM1和VM2配置floating IP,这样,外网即可以访问租户的VM,随便指出,从kilo开始,用户可以指定floating IP了,以前是openstack neutron随即生成的,
用户无法指定具体的IP。
floating ip配置前:
[root@controller ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+-----------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+-----------------------+
| 8d7db991-bd78-41ca-bf06-1c6c2869368a | test1 | ACTIVE | - | Running | demo-net=192.168.1.5 |
| 7b086c8a-9a94-4360-8148-6099cb6b5388 | test2 | ACTIVE | - | Running | demo-net2=192.168.2.4 |
+--------------------------------------+-------+--------+------------+-------------+-----------------------+
floating ip配置后:
[root@controller ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------+
| 8d7db991-bd78-41ca-bf06-1c6c2869368a | test1 | ACTIVE | - | Running | demo-net=192.168.1.5, 192.168.115.157 |
| 7b086c8a-9a94-4360-8148-6099cb6b5388 | test2 | ACTIVE | - | Running | demo-net2=192.168.2.4, 192.168.115.159 |
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------+
在compute节点和network节点上观察网络命名空间namespace的变化:
[root@network ~]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
10: qr-3aeb9186-67: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:32:c5:eb brd ff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global qr-3aeb9186-67
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe32:c5eb/64 scope link
valid_lft forever preferred_lft forever
12: qr-52218be2-97: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:b2:50:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global qr-52218be2-97
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feb2:509a/64 scope link
valid_lft forever preferred_lft forever
网络节点上的qrouter没有任何变化。
[root@network ~]# ip netns exec snat-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
11: sg-416d8a05-df: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:18:4a:21 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.3/24 brd 192.168.2.255 scope global sg-416d8a05-df
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe18:4a21/64 scope link
valid_lft forever preferred_lft forever
13: sg-f3407fd3-81: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:28:98:7d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.7/24 brd 192.168.1.255 scope global sg-f3407fd3-81
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe28:987d/64 scope link
valid_lft forever preferred_lft forever
14: qg-1b3cd60f-f5: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:c7:2a:6a brd ff:ff:ff:ff:ff:ff
inet 192.168.115.156/24 brd 192.168.115.255 scope global qg-1b3cd60f-f5
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fec7:2a6a/64 scope link
valid_lft forever preferred_lft forever
网络节点上的SNAT命名空间没有任何变化。
总结:为VM增加floating-IP后,network节点上的命名空间不会有任变化;
[root@compute /]# ip netns
fip-282bbb70-6903-4d3d-84ea-c2c8349ff11b
qrouter-aa791a83-c11c-4bef-b454-b1c53502e323
compute节点上增加了fip命名空间,fip命名空间的ID是外部网络的ID。
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip addr
2: rfp-aa791a83-c: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 2a:5c:29:62:5e:ee brd ff:ff:ff:ff:ff:ff
inet 169.254.31.28/31 scope global rfp-aa791a83-c
valid_lft forever preferred_lft forever
inet 192.168.115.157/32 brd 192.168.115.157 scope global rfp-aa791a83-c
valid_lft forever preferred_lft forever
inet6 fe80::285c:29ff:fe62:5eee/64 scope link
valid_lft forever preferred_lft forever
18: qr-52218be2-97: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:b2:50:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global qr-52218be2-97
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feb2:509a/64 scope link
valid_lft forever preferred_lft forever
20: qr-3aeb9186-67: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:32:c5:eb brd ff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global qr-3aeb9186-67
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe32:c5eb/64 scope link
valid_lft forever preferred_lft forever
[root@compute /]# ip netns exec fip-282bbb70-6903-4d3d-84ea-c2c8349ff11b ip addr
2: fpr-aa791a83-c: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 76:90:74:f5:eb:86 brd ff:ff:ff:ff:ff:ff
inet 169.254.31.29/31 scope global fpr-aa791a83-c
valid_lft forever preferred_lft forever
inet6 fe80::7490:74ff:fef5:eb86/64 scope link
valid_lft forever preferred_lft forever
21: fg-d991b7a6-14: mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:ca:d2:0a brd ff:ff:ff:ff:ff:ff
inet 192.168.115.158/24 brd 192.168.115.255 scope global fg-d991b7a6-14
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feca:d20a/64 scope link
valid_lft forever preferred_lft forever
1.外部网络如何通过floating ip进入私网中的VM内
[root@storage ~]# traceroute 192.168.115.157
traceroute to 192.168.115.157 (192.168.115.157), 30 hops max, 60 byte packets
1 192.168.115.158 (192.168.115.158) 1.898 ms 1.797 ms 1.717 ms
2 * * *
3 * * *
4 * * *
网络包首先到达192.168.115.158,不是157,这里存在一个arp欺骗,即外部网络通过floating ip进行ARP时候,获得的MAC并不是floating ip对应的接口MAC,而是fip命名空间中的fg接口的MAC
地址,这是因为在fip的fg接口上配置了ARP proxy的缘故。外部网络获得floatip的mac 地址后(实际上是fg接口的欺骗mac地址),开始向它解析到的MAC地址发送包,包通过br-ex后到达fip命名空间,
查询fip命名空间的路由:
[root@compute /]# ip netns exec fip-282bbb70-6903-4d3d-84ea-c2c8349ff11b ip route
default via 192.168.115.254 dev fg-d991b7a6-14
169.254.31.28/31 dev fpr-aa791a83-c proto kernel scope link src 169.254.31.29
192.168.115.0/24 dev fg-d991b7a6-14 proto kernel scope link src 192.168.115.158
192.168.115.157 via 169.254.31.28 dev fpr-aa791a83-c
可以看到到192.168.115.157的包需要经过fpr-aa791a83-c 设备先发送到169.254.31.28 ,而169.254.31.28 ip地址在qrouter的rfp-aa791a83-c接口上,因此外部网络包被fip转发到qrouter
命名空间中。
查看qrouter的命名空间路由:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N neutron-l3-agent-OUTPUT
-N neutron-l3-agent-POSTROUTING
-N neutron-l3-agent-PREROUTING
-N neutron-l3-agent-float-snat
-N neutron-l3-agent-snat
-N neutron-postrouting-bottom
-A PREROUTING -j neutron-l3-agent-PREROUTING
-A OUTPUT -j neutron-l3-agent-OUTPUT
-A POSTROUTING -j neutron-l3-agent-POSTROUTING
-A POSTROUTING -j neutron-postrouting-bottom
-A neutron-l3-agent-OUTPUT -d 192.168.115.157/32 -j DNAT --to-destination 192.168.1.5
-A neutron-l3-agent-POSTROUTING ! -i rfp-aa791a83-c ! -o rfp-aa791a83-c -m conntrack ! --ctstate DNAT -j ACCEPT
-A neutron-l3-agent-PREROUTING -d 169.254.169.254/32 -i qr-+ -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 9697
-A neutron-l3-agent-PREROUTING -d 192.168.115.157/32 -j DNAT --to-destination 192.168.1.5
-A neutron-l3-agent-float-snat -s 192.168.1.5/32 -j SNAT --to-source 192.168.115.157
-A neutron-l3-agent-snat -j neutron-l3-agent-float-snat
-A neutron-postrouting-bottom -m comment --comment "Perform source NAT on outgoing traffic." -j neutron-l3-agent-snat
通过规则:-A neutron-l3-agent-OUTPUT -d 192.168.115.157/32 -j DNAT --to-destination 192.168.1.5 进行DNAT转换,这是一个prerouting过程,转换后进入路由:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip route
169.254.31.28/31 dev rfp-aa791a83-c proto kernel scope link src 169.254.31.28
192.168.1.0/24 dev qr-52218be2-97 proto kernel scope link src 192.168.1.1
192.168.2.0/24 dev qr-3aeb9186-67 proto kernel scope link src 192.168.2.1
2.VM中的包如何通过floating ip进入外网
网络包从虚机触发,进入本服务器所在的 qrouter 的 qr interface,首先经过DNAT,没有命中,然后查路由表,local,main,default 中没有命中的路由规则,查表 16,命中默认路由,
需要经过 rfp 端口发到下一个路由器169.254.31.29:
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip rule
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
32768: from 192.168.1.5 lookup 16
3232235777: from 192.168.1.1/24 lookup 3232235777
3232236033: from 192.168.2.1/24 lookup 3232236033
[root@compute /]# ip netns exec qrouter-aa791a83-c11c-4bef-b454-b1c53502e323 ip route list table 16
default via 169.254.31.29 dev rfp-aa791a83-c
[root@compute /]# ip netns exec fip-282bbb70-6903-4d3d-84ea-c2c8349ff11b ip route
default via 192.168.115.254 dev fg-d991b7a6-14
169.254.31.28/31 dev fpr-aa791a83-c proto kernel scope link src 169.254.31.29
192.168.115.0/24 dev fg-d991b7a6-14 proto kernel scope link src 192.168.115.158
192.168.115.157 via 169.254.31.28 dev fpr-aa791a83-c
路由器169.254.31.29位于fip命名空间的fpr接口,进入fip后,根据路由规则:192.168.115.0/24 dev fg-d991b7a6-14 proto kernel scope link src 192.168.115.158 ,由fip命名空间
中的fg-d991b7a6-14接口转发到192.168.115.0/24网络的包,路由后进行SNAT,将源地址替换发送到外部网络。
Open Source Obfuscators
ProGuard
http://java-source.net/open-source/obfuscators/proguardProGuard is a free Java class file shrinker and obfuscator. It can detect and remove unused classes, fields, m
Maven简介
是什么?
Is a software project management and comprehension tool.项目管理工具
是基于POM概念(工程对象模型)
[设计重复、编码重复、文档重复、构建重复,maven最大化消除了构建的重复]
[与XP:简单、交流与反馈;测试驱动开发、十分钟构建、持续集成、富有信息的工作区]
功能:
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。
异常一:
make[2]: cc: Command not found
异常原因:没有安装g
nimbus结点配置(storm.yaml)信息:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional inf