Linux使用LVS DR或者阿里云的SLB TCP模式转发时,需要关闭rp_filter参数,否则会造成健康检查正常,但是端口不通的情况。
随着Windows系统的升级,在Windows2008以上版本, 也有了这样类似功能的参数weakhostsend(中文版系统叫弱主机),如果弱主机发送接收被禁用,就会导致阿里云TCP协议的SLB转发异常。win/linux下这个参数的功能是类似的,都是为了 防止跨接口转发数据包。
我们来测试一下:
1
2
|
SLB
VIP
:
101.201.178.107
ECS
公网
IP:
123.57.147.200
|
SLB配置,前后端都是用TCP协议的3389,如下:
查看目前的配置
01 | PS C:\Users\Administrator> netsh interface ipv4 show interface 本地连接 |
02 |
03 | 接口 本地连接 参数 |
04 | ---------------------------------------------- |
05 | IfLuid : ethernet_14 |
06 | IfIndex : 14 |
07 | 状态 : connected |
08 | 跃点数 : 10 |
09 | 链接 MTU : 1500 字节 |
10 | 可访问时间 : 41000 毫秒 |
11 | 基本可访问时间 : 30000 毫秒 |
12 | 重传间隔 : 1000 毫秒 |
13 | DAD 传输 : 3 |
14 | 站点前缀长度 : 64 |
15 | 站点 ID : 1 |
16 | 转发 : disabled |
17 | 播发 : disabled |
18 | 邻居发现 : enabled |
19 | 邻居无法访问检测 : enabled |
20 | 路由器发现 : dhcp |
21 | 受管理的地址配置 : enabled |
22 | 其他有状态的配置 : enabled |
23 | 弱主机发送 : enabled |
24 | 弱主机接收 : enabled |
25 | 使用自动跃点数 : enabled |
26 | 忽略默认路由 : disabled |
27 | 播发的路由器生存时间 : 1800 秒 |
28 | 播发默认路由 : disabled |
29 | 当前跃点限制 : 0 |
30 | 强制 ARPND 唤醒模式 : disabled |
31 | 定向 MAC 唤醒模式 : disabled |
32 | ECN 功能 : application |
通过SLB的IP可以正常远程登录ECS:
修改本地连接的配置,禁用掉若主机发送接收
1 | netsh interface ipv4 set interface "本地连接" weakhostreceive=disable |
2 | netsh interface ipv4 set interface "本地连接" weakhostsend=disable |
这时候直接访问ECS的IP还是可以正常远程的,但是通过SLB的VIP已经无法远程了,如下图:
修复也很简单,将网卡的 weakhostreceive/ weakhostsend 启用即可:
1 | netsh interface ipv4 set interface "本地连接" weakhostreceive= enable |
2 | netsh interface ipv4 set interface "本地连接" weakhostsend= enable |
服务器上多块网卡,都需要看一看这个设置。