![Minecraft 如何寻找 LAN 服务器?](https://linux22.com/image/1504826/Minecraft%20%E5%A6%82%E4%BD%95%E5%AF%BB%E6%89%BE%20LAN%20%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%9F.png)
Minecraft 客户端(当您进入“多人游戏”模式时)显示“正在扫描 LAN 以查找本地服务器...”
它在做什么?
这是我的问题:如果计算机 A 和计算机 B 通过 Switch1 连接在一起,那么计算机 A 可以运行 minecraft 客户端并在计算机 B 上找到 minecraft 服务器。 但如果计算机C通过Switch2连接,C看不到B上运行的服务器。但是,C可以ping通B,并且如果直接输入此IP和端口,C可以连接到10.1.10.143:64134的服务器。
因此,客户端定位服务器的机制以某种方式被 Switch2 阻止。这是 UPnP 吗?还是类似的东西?
它是巨大的痛苦每次启动 minecraft 服务器时跟踪变化的 IP 地址和变化的端口号。
答案1
我在 Wireshark 上进行了一些数据包捕获,据我所知,它使用 IGMPv2 数据包发送到较少使用的多播地址 (224.0.2.60),要求运行 Minecraft 服务器的任何人报告。它使用“成员报告”来执行此操作。
对于技术爱好者来说,这里是完整的数据包转储信息:
Frame 10: 46 bytes on wire (368 bits), 46 bytes captured (368 bits) on interface 0
Interface id: 0 (\Device\NPF_{F0A28F43-6094-447F-A150-434AFC4BB19B})
Encapsulation type: Ethernet (1)
Arrival Time: Aug 25, 2016 22:25:55.171363000 US Mountain Standard Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1472189155.171363000 seconds
[Time delta from previous captured frame: 0.235431000 seconds]
[Time delta from previous displayed frame: 0.235431000 seconds]
[Time since reference or first frame: 1.234950000 seconds]
Frame Number: 10
Frame Length: 46 bytes (368 bits)
Capture Length: 46 bytes (368 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:igmp:igmp]
[Coloring Rule Name: Routing]
[Coloring Rule String: hsrp || eigrp || ospf || bgp || cdp || vrrp || carp || gvrp || igmp || ismp]
Ethernet II, Src: Giga-Byt_91:9c:dc (fc:aa:14:91:9c:dc), Dst: IPv4mcast_02:3c (01:00:5e:00:02:3c)
Destination: IPv4mcast_02:3c (01:00:5e:00:02:3c)
Address: IPv4mcast_02:3c (01:00:5e:00:02:3c)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
Source: Giga-Byt_91:9c:dc (fc:aa:14:91:9c:dc)
Address: Giga-Byt_91:9c:dc (fc:aa:14:91:9c:dc)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 192.168.1.46, Dst: 224.0.2.60
0100 .... = Version: 4
.... 0110 = Header Length: 24 bytes
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Total Length: 32
Identification: 0x4347 (17223)
Flags: 0x00
0... .... = Reserved bit: Not set
.0.. .... = Don't fragment: Not set
..0. .... = More fragments: Not set
Fragment offset: 0
Time to live: 1
Protocol: IGMP (2)
Header checksum: 0x0000 [validation disabled]
[Good: False]
[Bad: False]
Source: 192.168.1.46
Destination: 224.0.2.60
[Source GeoIP: Unknown]
[Destination GeoIP: Unknown]
Options: (4 bytes), Router Alert
Router Alert (4 bytes): Router shall examine packet (0)
Type: 148
1... .... = Copy on fragmentation: Yes
.00. .... = Class: Control (0)
...1 0100 = Number: Router Alert (20)
Length: 4
Router Alert: Router shall examine packet (0)
Internet Group Management Protocol
[IGMP Version: 2]
Type: Membership Report (0x16)
Max Resp Time: 0.0 sec (0x00)
Header checksum: 0x07c3 [correct]
Multicast Address: 224.0.2.60
以下是原始数据包转储:
0000 01 00 5e 00 02 3c fc aa 14 91 9c dc 08 00 46 00 ..^..<........F.
0010 00 20 43 47 00 00 01 02 00 00 c0 a8 01 2e e0 00 . CG............
0020 02 3c 94 04 00 00 16 00 07 c3 e0 00 02 3c .<...........<
因此,要回答您的问题,您可能在路由器上关闭了多播,或者禁用了 IGMP。我不太熟悉这些标志,但看起来选项/路由器警报字段中可能有一些内容……可能告诉路由器不要将多播转发到子网之外,但这只是猜测。