6

The Minecraft client (when you enter "multiplayer" mode) says "Scanning LAN for Local Servers..."

What is it doing?

Here's my problem: if computer A and computer B are connected together through Switch1, then computer A can run the minecraft client and find a minecraft server on computer B. But if computer C is connected through Switch2, C cannot see the server running on B. However, C can ping B, and C can connect to the server at 10.1.10.143:64134 if this IP/port are directly entered.

So the mechanism by which clients locate servers is somehow blocked by Switch2. Is this UPnP? Or something similar?

It's a huge pain to keep track of the shifting IP addresses and shifting port numbers each time you start a minecraft server.

Fixee
  • 358

2 Answers2

7

I did a bit of packet capturing on Wireshark and to the best of what I can tell, it uses an IGMPv2 packet sent to a lesser used multicast address (224.0.2.60), asking for anyone running a Minecraft server to report back. It uses a "Membership report" to do this.

For the nerds, here is the complete packet dump info:

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

Here is the raw packet dump:

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        .<...........<

So to answer your problem, you might have multicasts turned off on your router, or IGMP is disabled. I'm not completely familiar with the flags, but it looks like it there might be something in the Options/Router Alert field… Probably telling the router to not forward the multicast outside of the subnet, but that's just a guess.

Giacomo1968
  • 58,727
Ian M
  • 248
4

I'm fairly sure the accepted answer is incorrect. (See tested versions listed at the end.) What Minecraft actually sends with "Open to LAN," and listens for when saying "Scanning for games on your local network," is a UDP multicast packet sent about once a second to 224.0.2.60:4445 with a message such as [MOTD]HostingUserName - WorldName[/MOTD][AD]12435[/AD] where 12345 is the hosting port number.

Methodology: SysInternals Process Monitor filtering to process name javaw.exe and using the toolbar buttons to filter to network activity only, plus Wireshark to examine the packets. No IGMP packets seem to be sent by Minecraft, but this UDP packet is sent. I also sent a UDP packet manually as a test, and it was autodiscovered by Minecraft.

Minecraft versions checked: 1.21.4, 1.9, 1.7.10, 1.4.7, 1.3.1 (the earliest version with the Open to LAN option).

To answer the question "why isn't it working," Minecraft seems to send to the first active network interface only. This is the behavior you get when you don't bind the socket to a specific network interface. In my case, my first active network interface listed in ipconfig was the Hyper-V vEthernet interface, and my LAN was second. I have reported this at https://report.bugs.mojang.com/servicedesk/customer/portal/2/MC-289175 and proposed the proof of concept shown below.

This likely also affects the receiving side. Minecraft is likely only listening on the default network interface on the receiving PC. If that's not its LAN interface, then it won't receive the message even if it's properly sent.

PowerShell to send an autodiscovery message to all network interfaces
$payload = '[MOTD]Your message here[/MOTD][AD]12345[/AD]'

$bytes = [System.Text.Encoding]::UTF8.GetBytes($payload)

foreach ($address in [System.Net.Dns]::GetHostEntry([System.Net.Dns]::GetHostName()).AddressList) { if ($address.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) { continue }

$udpClient = [System.Net.Sockets.UdpClient]::new()
$udpClient.Client.Bind(([IPEndPoint]::new($address, 0)))
[void] $udpClient.Send($bytes, $bytes.Length, '224.0.2.60', 4445)
$udpClient.Dispose()

}

Giacomo1968
  • 58,727
jnm2
  • 454