OpenStack 浮动 IP 关联在底层是如何工作的?

How does OpenStack Floating IP assocation work underneath?

我创建了约 10 个节点的 DevStack 安装,以了解有关 OpenStack 如何管理网络的更多信息。我创建了一些 VMS,并在一些主机上验证了它们,如下所示:

virsh # list
 Id    Name                           State
----------------------------------------------------
 2     instance-0000001b              running
 3     instance-0000001f              running
 4     instance-00000024              running
 5     instance-0000002c              running

我已将浮动 IP 关联到实例 ID 2,我通过查看其 openstack ID 并与 virsh dumpxml 2 的输出匹配来验证它。它具有以下浮动 IP:172.16.6.12 和本地 IP:10.4.128.11

我看到它使用 vnet0:

   <interface type='bridge'>
      <mac address='fa:16:3e:a1:f8:65'/>
      <source bridge='br100'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <filterref filter='nova-instance-instance-0000001b-fa163ea1f865'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

执行 ifconfig vnet0,显示没有 IP 地址:

vnet0     Link encap:Ethernet  HWaddr fe:16:3e:a1:f8:65  
          inet6 addr: fe80::fc16:3eff:fea1:f865/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:70 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44216 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:7232 (7.2 KB)  TX bytes:29123311 (29.1 MB)

当我执行 ip addr 时,我看到网桥中定义了 IP 地址,br100

4: br100: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether d8:50:e6:c3:22:ee brd ff:ff:ff:ff:ff:ff
    inet 10.4.128.13/20 brd 10.4.143.255 scope global br100
       valid_lft forever preferred_lft forever
    inet 172.16.0.101/21 brd 172.16.7.255 scope global br100
       valid_lft forever preferred_lft forever
    inet 172.16.6.12/32 scope global br100
       valid_lft forever preferred_lft forever
    inet 172.16.6.19/32 scope global br100
       valid_lft forever preferred_lft forever
    inet6 fe80::80b6:99ff:fef7:dc16/64 scope link 
       valid_lft forever preferred_lft forever
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br100 state UNKNOWN group default qlen 500
    link/ether fe:16:3e:a1:f8:65 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc16:3eff:fea1:f865/64 scope link 
       valid_lft forever preferred_lft forever

但是,vnet0 --> 172.16.6.12 (floating IP) 的关联在哪里?为什么来172.16.6.19的流量不去172.16.6.12,

我查找了iptables 规则,但没有显示vnet0 或浮动ip。这是怎么做到的?我看到它们与 brctl 桥接,但我看不到 IP-MAC 关联。它甚至不在 arp 表中。我查看了 iptables 或侦听端口是否在用户空间完成了任何转发,但事实并非如此。

bridge name bridge id       STP enabled interfaces
br100       8000.d850e6c322ee   no      eth0
                                        vnet0
                                        vnet1
                                        vnet2
                                        vnet3

好的,我找到了。我忘了看 iptables NAT 规则,它用于将给定的浮动 ip 转发到那个 veth 设备。