You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity多人扑克类游戏部署至DigitalOcean Droplet:Ubuntu16.04端口开放求助

Hey there! Let's walk through how to open the necessary ports on your DigitalOcean Ubuntu 16.04 Droplet for your Unity multiplayer poker game using Master Server Kit. I’ll break this down into simple, actionable steps since you mentioned you’re new to server management—no jargon overload, promise!

Step 1: Figure Out Which Ports Your Game Needs

First things first: you need to know exactly which ports your Master Server Kit and Unity game are using.

  • Check your Master Server Kit configuration files or settings panel. Common defaults are 23466 (for the master server, handling room creation/player joins) and 23467 (for the game server, handling in-game traffic), but don’t assume—verify your setup.
  • Unity’s default multiplayer port is often 7777, so double-check if your game uses that too.
Step 2: Open Ports with UFW (Ubuntu’s Built-in Firewall)

Ubuntu 16.04 comes with UFW (Uncomplicated Firewall) pre-installed, and it’s super straightforward to use. Here’s what to do:

  1. First, enable UFW if it’s not already running:
    sudo ufw enable
    
    You’ll get a warning about disrupting existing connections—just confirm with y if you’re sure you want to proceed.
  2. Allow incoming traffic for your game ports. Replace <PORT> with the actual numbers you found in Step 1. For example, if you’re using 23466 and 23467:
    # Allow TCP for master server (handles room/join requests)
    sudo ufw allow 23466/tcp
    # Allow UDP for game server (faster in-game traffic)
    sudo ufw allow 23467/udp
    

    Pro tip: If you’re unsure which protocol (TCP/UDP) your server uses, you can allow both for each port to cover your bases:

    sudo ufw allow 23466/tcp
    sudo ufw allow 23466/udp
    sudo ufw allow 23467/tcp
    sudo ufw allow 23467/udp
    
  3. Verify the rules are applied correctly by checking UFW’s status:
    sudo ufw status
    
    You should see your allowed ports listed in the output—this means traffic can now flow through those ports.
Step 3: Add a DigitalOcean Cloud Firewall (Extra Security Layer)

DigitalOcean has its own cloud-level firewall that adds another layer of protection on top of UFW. It’s optional but highly recommended:

  1. Log into your DigitalOcean control panel, go to your Droplet’s page.
  2. Click the "Firewalls" tab, then hit "Create Firewall".
  3. Name your firewall something descriptive, like "Game Server Firewall".
  4. Under "Inbound Rules", add new rules for each port:
    • For TCP ports: Select "TCP" as the protocol, enter the port number in "Port Range", and set "Sources" to "Anywhere" (so anyone can connect to your game).
    • For UDP ports: Do the same, but select "UDP" as the protocol.
  5. Attach the firewall to your Droplet, then save the changes.
Step 4: Update Your Unity Game to Use the Droplet’s IP

Now that the ports are open, you need to point your game to your Droplet’s public IP instead of the local Unity IP:

  • In your Master Server Kit settings, replace the local IP (like 127.0.0.1 or your home LAN IP) with your Droplet’s public IP address (you can find this in your DigitalOcean control panel).
  • Make sure all client builds are configured to connect to this public IP and the correct ports you opened.
Quick Troubleshooting Tips

If you run into issues connecting from a remote client:

  • Double-check UFW’s status with sudo ufw status to ensure your port rules are active.
  • Use this command to confirm your Master Server is actually listening on the right ports:
    sudo netstat -tulpn | grep <PORT_NUMBER>
    
    You should see your server process listed here—if not, your server might not be running correctly.
  • Ensure you don’t have other firewall tools (like iptables) running that could block traffic. UFW is the default for Ubuntu 16.04, but if you installed something else, you’ll need to configure that too.

内容的提问来源于stack exchange,提问作者Tabi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:44:27