DVR模式绑定浮动IP的情况下:
从虚拟机(10.10.10.12)ping 114.114.114.114
[root@vm-hanbo ~]# ping 114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=91 time=32.3 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=67 time=33.0 ms
此时虚拟机还没有绑定FIP,计算节点 bond1 接口未抓到包
[root@compute~]# tcpdump -i bond1 dst 114.114.114.114
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond1, link-type EN10MB (Ethernet), capture size 262144 bytes
给虚拟机绑定浮动 IP
openstack server add floating ip vm-snat 8.1.6.240
计算节点的 qrouter 会比没绑定浮动IP之前多一个 rule
[root@compute ~]# ip netns exec qrouter-d02c9901-d249-4189-a286-1477b7522d0a ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: rfp-d02c9901-d@if94: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 9a:63:cc:54:99:0f brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 169.254.124.74/31 scope global rfp-d02c9901-d
valid_lft forever preferred_lft forever
inet6 fe80::9863:ccff:fe54:990f/64 scope link
valid_lft forever preferred_lft forever
362: qr-bfa48add-83: mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
link/ether fa:16:3e:ff:e8:26 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.1/24 brd 10.10.10.255 scope global qr-bfa48add-83
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:feff:e826/64 scope link
valid_lft forever preferred_lft forever
[root@compute ~]# ip netns exec qrouter-d02c9901-d249-4189-a286-1477b7522d0a ip rule
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
46799: from 10.10.10.12 lookup 16
168430081: from 10.10.10.1/24 lookup 168430081
[root@compute ~]# ip netns exec qrouter-d02c9901-d249-4189-a286-1477b7522d0a ip route list table 16
default via 169.254.124.75 dev rfp-d02c9901-d
[root@10e129e168e38 ~]#
[root@compute ~]# ip netns exec qrouter-d02c9901-d249-4189-a286-1477b7522d0a 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 rfp-d02c9901-d ! -o rfp-d02c9901-d -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 8.1.6.240/32 -i rfp-d02c9901-d -j DNAT --to-destination 10.10.10.12
-A neutron-l3-agent-float-snat -s 10.10.10.12/32 -j SNAT --to-source 8.1.6.240 # 源地址转换为 8.1.6.240
-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
来源 10.10.10.12 的网络包,通过 snat 8.1.6.240 换成,再匹配rule 规则,通过 169.254.124.74 ( rfp-d02c9901-d) 发往 169.254.124.75 ( fip netns )
计算节点会生成一个 fip netns
[root@compute ~]# ip netns |grep 69d89878-4049-46a4-8ebd-fe4e40cac114 # network_id
fip-69d89878-4049-46a4-8ebd-fe4e40cac114
[root@10e129e168e38 ~]#
[root@compute ~]# ip netns exec fip-69d89878-4049-46a4-8ebd-fe4e40cac114 ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
4: fpr-3d586d48-f@if2: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 52:7d:6e:7e:da:22 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 169.254.109.47/31 scope global fpr-3d586d48-f
valid_lft forever preferred_lft forever
inet6 fe80::507d:6eff:fe7e:da22/64 scope link
valid_lft forever preferred_lft forever
23: fg-2a49a502-53: mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
link/ether fa:16:3e:71:e3:72 brd ff:ff:ff:ff:ff:ff
inet 172.28.16.32/24 brd 172.28.16.255 scope global fg-2a49a502-53
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe71:e372/64 scope link
valid_lft forever preferred_lft forever
94: fpr-d02c9901-d@if2: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether aa:73:0d:36:d9:c3 brd ff:ff:ff:ff:ff:ff link-netnsid 5
inet 169.254.124.75/31 scope global fpr-d02c9901-d
valid_lft forever preferred_lft forever
inet6 fe80::a873:dff:fe36:d9c3/64 scope link
valid_lft forever preferred_lft forever
96: fpr-fe03d316-0@if2: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 6e:14:4f:8d:5d:f7 brd ff:ff:ff:ff:ff:ff link-netnsid 4
inet 169.254.79.247/31 scope global fpr-fe03d316-0
valid_lft forever preferred_lft forever
inet6 fe80::6c14:4fff:fe8d:5df7/64 scope link
valid_lft forever preferred_lft forever
[root@compute ~]# ip netns exec fip-69d89878-4049-46a4-8ebd-fe4e40cac114 ip route # 查看路由规则
8.1.0.16 via 169.254.89.172 dev fpr-6f1f9a49-1
8.1.0.37 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.44 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.49 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.53 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.70 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.80 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.93 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.94 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.116 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.123 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.140 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.142 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.146 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.156 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.177 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.179 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.194 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.204 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.230 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.246 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.252 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.0.253 via 169.254.124.224 dev fpr-c6b6e033-7
8.1.6.240 via 169.254.124.74 dev fpr-d02c9901-d # #
169.254.79.246/31 dev fpr-fe03d316-0 proto kernel scope link src 169.254.79.247
169.254.89.172/31 dev fpr-6f1f9a49-1 proto kernel scope link src 169.254.89.173
169.254.109.46/31 dev fpr-3d586d48-f proto kernel scope link src 169.254.109.47
169.254.124.74/31 dev fpr-d02c9901-d proto kernel scope link src 169.254.124.75 # #
169.254.124.224/31 dev fpr-c6b6e033-7 proto kernel scope link src 169.254.124.225
169.254.125.226/31 dev fpr-9f813942-3 proto kernel scope link src 169.254.125.227
172.28.16.0/24 dev fg-2a49a502-53 proto kernel scope link src 172.28.16.32
172.28.17.254 dev fg-2a49a502-53 scope link
[root@compute ~]# ip rule
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
2852016119: from all iif fpr-fe03d316-0 lookup 2852016119
2852018605: from all iif fpr-6f1f9a49-1 lookup 2852018605
2852023599: from all iif fpr-3d586d48-f lookup 2852023599
2852027467: from all iif fpr-d02c9901-d lookup 2852027467
2852027617: from all iif fpr-c6b6e033-7 lookup 2852027617
2852027875: from all iif fpr-9f813942-3 lookup 2852027875
[root@compute ~]# ip route show table 2852016119
default via 172.28.17.254 dev fg-2a49a502-53 # fg-2a49a502-53 发出
[root@compute ~]# ip netns exec fip-69d89878-4049-46a4-8ebd-fe4e40cac114 ip a |grep fg-2a49a502-53
23: fg-2a49a502-53: mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
inet 172.28.16.32/24 brd 172.28.16.255 scope global fg-2a49a502-53
fg-2a49a502-53 >> br-int >> br-ex >> bond1
计算节点 bond1 接口抓到浮动IP的包
[root@compute ~]# tcpdump -i bond1 src 8.1.6.240
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond1, link-type EN10MB (Ethernet), capture size 262144 bytes
19:04:56.465284 IP 8.1.6.240 > public1.114dns.com: ICMP echo request, id 6981, seq 3571, length 64
19:04:57.467195 IP 8.1.6.240 > public1.114dns.com: ICMP echo request, id 6981, seq 3572, length 64
19:04:58.468339 IP 8.1.6.240 > public1.114dns.com: ICMP echo request, id 6981, seq 3573, length 64
19:04:59.470156 IP 8.1.6.240 > public1.114dns.com: ICMP echo request, id 6981, seq 3574, length 64