Last updated on

[LAB] OPENELB Layer2


TOPO

image

  • LB CIDR - 10.100.100.200-10.100.100.200

Enable Strict ARP

Verify ARP Config

arp_ignore的意义

⚠️ 访问ARP响应被其他的网卡进行抢答

LVS三种模式的工作原理

本文主要包括LVS三种模式的基本工作原理介绍和可能涉及的ARP问题原理。

arp_ignore - INTEGER

Define different modes for sending replies in response to received ARP requests that resolve local target IP addresses:

  • 0 - (default): reply for any local target IP address, configured on any interface 0-(默认): 回复任何本地目标ip地址,在任何接口上配置

  • 1 - reply only if the target IP address is local address configured on the incoming interface 1-仅当目标ip地址是在传入接口上配置的本地地址时才回复

  • 2 - reply only if the target IP address is local address configured on the incoming interface and both with the sender’s IP address are part from same subnet on this interface 2-仅当目标ip地址是在传入接口上配置的本地地址,并且具有发件人ip地址的两者均来自该接口上的同一子网时,才进行答复

  • 3 - do not reply for local addresses configured with scope host, only resolutions for global and link addresses are replied 3 - 不回复使用范围主机配置的本地地址,仅回复全局和链接地址的解析

  • 4 - 7 - reserved 4-7-保留

  • 8 - do not reply for all local addresses The max value from conf/{all,interface}/arp_ignore is used when ARP request is received on the {interface} 8 - 不要为所有本地地址回复当在 {interface} 上接收到ARP请求时,使用来自conf/{all,interface}/arp_ignore的最大值

image

image

arp_annouce的意义

⚠️ 防止出现错误的ARP表项记录

arp_announce - INTEGER

Define different restriction levels for announcing the local source IP address from IP packets in ARP requests sent on interface:
定义不同的限制级别,用于从接口上发送的ARP请求中的IP数据包中宣布本地源ip地址:

  • 0 - (default) Use any local address, configured on any interface 0-(默认) 使用任何本地地址,在任何接口上配置

  • 1 - Try to avoid local addresses that are not in the target’s subnet for this interface. This mode is useful when target hosts reachable via this interface require the source IP address in ARP requests to be part of their logical network configured on the receiving interface. When we generate the request we will check all our subnets that include the target IP and will preserve the source address if it is from such subnet. If there is no such subnet we select source address according to the rules for level 2. 1-尽量避免不在该接口的目标子网中的本地地址。当可通过此接口访问的目标主机要求ARP请求中的源ip地址成为其在接收接口上配置的逻辑网络的一部分时,此模式很有用。当我们生成请求时,我们将检查包括目标IP的所有子网,如果源地址来自这样的子网,我们将保留源地址。如果没有这样的子网,我们将根据级别2的规则选择源地址。

  • 2 - Always use the best local address for this target. In this mode we ignore the source address in the IP packet and try to select local address that we prefer for talks with the target host. Such local address is selected by looking for primary IP addresses on all our subnets on the outgoing interface that include the target IP address. If no suitable local address is found we select the first local address we have on the outgoing interface or on all other interfaces, with the hope we will receive reply for our request and even sometimes no matter the source IP address we announce. The max value from conf/{all,interface}/arp_announce is used. 2-始终为此目标使用最佳本地地址。在这种模式下,我们忽略IP数据包中的源地址,并尝试选择我们更喜欢与目标主机进行对话的本地地址。通过在包括目标ip地址的传出接口上查找我们所有子网上的主ip地址来选择此类本地地址。如果找不到合适的本地地址,我们会选择我们在传出接口或所有其他接口上拥有的第一个本地地址,希望我们会收到对我们请求的回复,甚至有时无论我们宣布的源ip地址如何。使用conf/{all,interface}/arp_nouncing中的最大值。

每个机器或者交换机中都有一张ARP表,ARP表的作用就是用于记录IP地址和MAC地址的对应关系。当收到一个ARP表中没有记录的IP地址的ARP请求,就会在本机的ARP表中新增对应的IP和MAC记录;当收到一个已知IP地址(arp表中已有记录的地址)的arp请求,则会根据arp请求中的源MAC刷新自己的arp表。

如果arp_announce参数配置为0,则网卡在发送arp请求时,可能选择的源IP地址并不是该网卡自身的IP地址,这时候收到该arp请求的其他节点或者交换机上的arp表中记录的该网卡IP和MAC的对应关系就不正确。

  • 在这个模式下会忽略IP数据包中的源地址并且尝试选择能与目标地址主机通信的本机地址

  • 首先就是查找本机所有的出口网卡上的IP地址所属的子网里面包含了目标的IP地址的IP

  • 如果没有上述的合适的IP地址,那么就会选择出口网卡的第一个IP地址或者是在所有的网卡中最有可能能够接收到请求的IP地址

Install OPENELB

Define EIP Pool

Test