When setting casual LAN Minecraft gaming, I'd find it would be easier and more user friendly if LAN clients just see the local Minecraft server automatically in the Multiplayer screen instead of typing in the IP. Can this be accomplished?
I found this Python script - "Advertising Linux Minecraft Servers to the LAN" that worked well for me:
My 5 year old son is really in to playing Minecraft at the moment and always wants me to play with him. I set up a couple of Minecraft servers on a Linux machine on my local network so that any of us could hop in and out from any computer. Annoyingly I found that the server for Linux does not broadcast its whereabouts to the LAN, so I had to manually enter the address and ports of the servers on every client.
Well that seemed unnecessary so I opened up Wireshark to see how the Windows and Mac clients announce their LAN games and came up with the following script. I decided to use Python simply because it was pre-installed on my Linux box and I didn’t want to install another language such as PHP just to handle this simple job. That said, I don’t know Python very well.
I run this script in a screen session on the Linux server. It announces the Minecraft servers to the LAN every 1.5 seconds using a UDP broadcast to the subnet. The clients always assume that the source IP of the broadcast is also the IP address of the Minecraft server, so this script must be run on the same box that is hosting the Minecraft servers. In other words, you can’t use this script to announce the whereabouts of a Minecraft server on a different machine. I believe that’s a protocol change to previous versions where this was indeed possible. At the time of writing, the current Minecraft version is 1.8.
You can add as many servers are you like to the servers array. The array contains arrays consisting of the server description and the port number.
import socket import time servers = [ ["Local Network - Survival Map", 25565], ["Local Network - Creative Playground", 25566] ] BROADCAST_IP = "255.255.255.255" BROADCAST_PORT = 4445 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) print "Broadcasting Minecraft servers to LAN" while 1: for server in servers: msg = "[MOTD]%s[/MOTD][AD]%d[/AD]" % (server, server) sock.sendto(msg, (BROADCAST_IP, BROADCAST_PORT)) time.sleep(1.5)
If you're using Bukkit to run your server, I'd suggest getting the LANBroadcaster plugin.
If you're running a Vanilla server, there's no option to do so. (Try
If you're running a LAN game through the actual game (Pause menu > "Open to LAN", or
/broadcast), it should appear on their multiplayer lists.*
*If it doesn't appear, something may be wrong with your network, or their (the people trying to connect to you)'s network discovery. In that case: They'll need to tweak their firewall settings.