Networking & Ports¶
A server listens on two ports. Both need to be reachable by the players who should be able to join.
| Port | Protocol | Used for |
|---|---|---|
| 20770 | UDP | Game traffic like entits sync, player movement, world state |
| 20770 | TCP | Bundles are downloaded over this port |
| 20771 | UDP | Voice chat |
| 20771 | TCP | Voice chat |
Binding to a specific interface¶
By default the server accepts connections on every interface, over both IPv4
and IPv6. If your machine has several interfaces and you want the server on
only one of them, set the address in cfg/server.cfg:
This setting can only be changed from a config file, and changing it requires a restart. If the address or port cannot be used, the server fails to start and reports it in the log.
Connecting to your server¶
There are multiple ways to connect to a server.
You can:
- Open the console, use
connect <addr>:<port> or <srv_record_dns_name> - Connect to a server hosted on the default port on your local machine via Connect to Local Server
- Use the server browser to join an online server
See Connecting for how players join, including the server browser.
Changing the ports¶
In a container, GAME_PORT and VOIP_PORT set the ports on both sides at
once:
ports:
- "${GAME_PORT:-20770}:${GAME_PORT:-20770}/udp"
- "${GAME_PORT:-20770}:${GAME_PORT:-20770}/tcp"
- "${VOIP_PORT:-20771}:${VOIP_PORT:-20771}/tcp"
- "${VOIP_PORT:-20771}:${VOIP_PORT:-20771}/udp"
environment:
GAME_PORT: "30770"
VOIP_PORT: "30771"
Without containers, set sv_bindaddr and the voice address in
cfg/server.cfg instead.
Firewall¶
Depending on your installation you need to add firewall exceptions for the server.
#ufw
sudo ufw allow 20770/tcp
sudo ufw allow 20770/udp
sudo ufw allow 20771/tcp
sudo ufw allow 20771/udp
sudo ufw reload
#iptables
sudo iptables -A INPUT -p tcp --dport 20770 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 20770 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 20771 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 20771 -j ACCEPT
On windows, run wf.msc and create an incomming rule for
TCP and UDP for both ports.
Next steps¶
- Updates to configure update and restart policy
- Troubleshooting if players cannot connect