【发布时间】:2022-01-19 22:03:12
【问题描述】:
我有一个管理器和一个工作节点,管理器在云上,工作器是我的个人计算机,因此它们位于不同的子网上。两者都被列为 ACTIVE。
我的主要问题是创建服务并对其进行扩展按预期工作,管理器和工作人员都启动了容器等,但网状路由器不起作用。容器包含一个简单的乒乓类型服务器,如果规模为 1 并且只有管理器运行容器,那么我应该能够 cURL 我的工作人员并通过工作程序节点从管理器获取响应,对吗?
如果只有一个工人和许多容器,负载平衡按预期工作,但如果有 3 个工人和 3 个容器分布在它们之间,则负载平衡不起作用。
我确保所需端口已打开;
| IP Address | Start Port | End Port | Start Port | End Port | Protocol | Description | Enabled |
|---|---|---|---|---|---|---|---|
| 192.168.0.20 | 8080 | 8080 | 8080 | 8080 | Both | test-port | Yes |
| 192.168.0.20 | 7946 | 7946 | 7946 | 7946 | Both | Yes | |
| 192.168.0.20 | 4789 | 4789 | 4789 | 4789 | UDP | Yes | |
| 192.168.0.20 | 1234 | 1234 | 1234 | 1234 | Both | Yes | |
| 192.168.0.20 | 2377 | 2377 | 2377 | 2377 | TCP | Yes |
当我检查入口网络时,它显示 Peers 属性中的 worker 和 manager 都显示,但 worker 的 IP 显示在本地。
"Peers": [
{
"Name": "1fc94f7e314e",
"IP": "95.***.***.***"
},
{
"Name": "85d4a1a1b3f2",
"IP": "192.168.0.20"
},
]
编辑;添加 7946 端口的 tcpdump。4789 端口处于静默状态。
94.***.***.***.35388 > 95.***.***.***.7946: Flags [P.], cksum 0xea01 (correct), seq 1:302, ack 1, win 502, options [nop,nop,TS val 311036725 ecr 954017851], length 301
14:21:04.266975 IP (tos 0x0, ttl 64, id 54940, offset 0, flags [DF], proto TCP (6), length 52)
95.***.***.***.7946 > 94.***.***.***.35388: Flags [.], cksum 0x15df (incorrect -> 0x6e42), ack 302, win 507, options [nop,nop,TS val 954017925 ecr 311036725], length 0
14:21:04.267014 IP (tos 0x0, ttl 47, id 49773, offset 0, flags [DF], proto TCP (6), length 52)
94.***.***.***.35388 > 95.***.***.***.7946: Flags [.], cksum 0x6fbf (correct), ack 1, win 502, options [nop,nop,TS val 311036724 ecr 954017851], length 0
14:21:04.267028 IP (tos 0x0, ttl 64, id 54941, offset 0, flags [DF], proto TCP (6), length 52)
95.***.***.***.7946 > 94.***.***.***.35388: Flags [.], cksum 0x15df (incorrect -> 0x6e42), ack 302, win 507, options [nop,nop,TS val 954017925 ecr 311036725], length 0
14:21:04.267720 IP (tos 0x0, ttl 64, id 54942, offset 0, flags [DF], proto TCP (6), length 328)
95.***.***.***.7946 > 94.***.***.***.35388: Flags [P.], cksum 0x16f3 (incorrect -> 0xb31d), seq 1:277, ack 302, win 507, options [nop,nop,TS val 954017925 ecr 311036725], length 276
14:21:04.267815 IP (tos 0x0, ttl 64, id 54943, offset 0, flags [DF], proto TCP (6), length 52)
95.***.***.***.7946 > 94.***.***.***.35388: Flags [F.], cksum 0x15df (incorrect -> 0x6d2d), seq 277, ack 302, win 507, options [nop,nop,TS val 954017925 ecr 311036725], length 0
14:21:04.341436 IP (tos 0x0, ttl 47, id 49775, offset 0, flags [DF], proto TCP (6), length 52)
94.***.***.***.35388 > 95.***.***.***.7946: Flags [.], cksum 0x6cea (correct), ack 277, win 501, options [nop,nop,TS val 311036799 ecr 954017925], length 0
14:21:04.341516 IP (tos 0x0, ttl 47, id 49776, offset 0, flags [DF], proto TCP (6), length 52)
94.***.***.***.35388 > 95.***.***.***.7946: Flags [F.], cksum 0x6ce8 (correct), seq 302, ack 278, win 501, options [nop,nop,TS val 311036799 ecr 954017925], length 0
14:21:04.341554 IP (tos 0x0, ttl 64, id 54944, offset 0, flags [DF], proto TCP (6), length 52)
95.***.***.***.7946 > 94.***.***.***.35388: Flags [.], cksum 0x15df (incorrect -> 0x6c98), ack 303, win 507, options [nop,nop,TS val 954017999 ecr 311036799], length 0
14:21:04.572411 IP (tos 0x0, ttl 64, id 31955, offset 0, flags [DF], proto UDP (17), length 115)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 87
14:21:04.772361 IP (tos 0x0, ttl 64, id 31958, offset 0, flags [DF], proto UDP (17), length 115)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 87
14:21:04.972568 IP (tos 0x0, ttl 64, id 31990, offset 0, flags [DF], proto UDP (17), length 115)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 87
^[[A14:21:05.172449 IP (tos 0x0, ttl 64, id 32014, offset 0, flags [DF], proto UDP (17), length 115)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 87
14:21:05.372687 IP (tos 0x0, ttl 64, id 32045, offset 0, flags [DF], proto UDP (17), length 150)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 122
14:21:05.416490 IP (tos 0x0, ttl 47, id 64487, offset 0, flags [DF], proto UDP (17), length 86)
94.***.***.***.7946 > 95.***.***.***.7946: UDP, length 58
14:21:05.416902 IP (tos 0x0, ttl 64, id 16979, offset 0, flags [DF], proto UDP (17), length 77)
95.***.***.***.7946 > 94.***.***.***.7946: UDP, length 49
14:21:05.873535 IP (tos 0x0, ttl 64, id 24571, offset 0, flags [DF], proto TCP (6), length 60)
95.***.***.***.52398 > 192.168.0.20.7946: Flags [S], cksum 0x272d (incorrect -> 0x98a2), seq 1269859057, win 64240, options [mss 1460,sackOK,TS val 2080921355 ecr 0,nop,wscale 7], length 0
14:21:06.875553 IP (tos 0x0, ttl 64, id 24572, offset 0, flags [DF], proto TCP (6), length 60)
95.***.***.***.52398 > 192.168.0.20.7946: Flags [S], cksum 0x272d (incorrect -> 0x94b8), seq 1269859057, win 64240, options [mss 1460,sackOK,TS val 2080922357 ecr 0,nop,wscale 7], length 0
14:21:07.067513 IP (tos 0x0, ttl 64, id 35091, offset 0, flags [DF], proto TCP (6), length 60)
95.***.***.***.52396 > 192.168.0.20.7946: Flags [S], cksum 0x272d (incorrect -> 0x85cc), seq 2586264232, win 64240, options [mss 1460,sackOK,TS val 2080922549 ecr 0,nop,wscale 7], length 0
14:21:07.372802 IP (tos 0x0, ttl 64, id 25130, offset 0, flags [DF], proto TCP (6), length 60)
95.***.***.***.52400 > 192.168.0.20.7946: Flags [S], cksum 0x272d (incorrect -> 0xf2ef), seq 603998839, win 64240, options [mss 1460,sackOK,TS val 2080922854 ecr 0,nop,wscale 7], length 0
14:21:07.416945 IP (tos 0x0, ttl 47, id 64591, offset 0, flags [DF], proto UDP (17), length 86)
94.***.***.***.7946 > 95.***.***.***.7946: UDP, length 58
14:21:07.417352 IP (tos 0x0, ttl 64, id 17071, offset 0, flags [DF], proto UDP (17), length 77)
95.***.***.***.7946 > 94.***.***.***.7946: UDP, length 49
14:21:08.379558 IP (tos 0x0, ttl 64, id 25131, offset 0, flags [DF], proto TCP (6), length 60)
95.***.***.***.52400 > 192.168.0.20.7946: Flags [S], cksum 0x272d (incorrect -> 0xef00), seq 603998839, win 64240, options [mss 1460,sackOK,TS val 2080923861 ecr 0,nop,wscale 7], length 0
14:21:08.572575 IP (tos 0x0, ttl 64, id 32740, offset 0, flags [DF], proto UDP (17), length 115)
95.***.***.***.7946 > 192.168.0.20.7946: UDP, length 87
所以总结一下;网状路由器的负载平衡适用于本地网络,但不适用于远程工作人员/容器。
【问题讨论】:
-
您是否进行了 tcpdump 以验证从一个网络发送的覆盖数据包是否已在另一个网络上接收?
-
@BMitch 是的,对于端口 7946 和 4789。已经看到了数据包。
-
@BMitch 添加了转储,但正如我所写的,4789 端口是静默的,7946 的校验和不正确。
-
我还看到您的回复,指出 docker swarm 需要 VPN 才能在公共互联网上运行。
-
“可能需要VPN”取决于一个人的具体情况,而“需要VPN......在公共互联网上运行”对我来说是非常不同的短语。听起来您已经确认网络正在阻止数据包。
标签: docker docker-swarm docker-swarm-mode