π€ Play together
The one-time fix for βwhen I join while somebody else is in the game, one of us gets thrown outβ.
Why it happens. Civ4 connects every player directly to every other player, even on a Pitboss server. Two people behind home routers can't open that connection on their own, so the game asks GameSpy's βNAT negotiationβ servers to broker it β and those have been dead since 2014. The game waits, gives up, and drops one of you. Joining alone always works because the server itself has a public address.
The fix. Tell your PC that the GameSpy hostnames now live at civpb.com. Our server answers in GameSpy's place and relays the connection between the two of you, so it works even on mobile or CGNAT internet, with no port forwarding. That's the whole change: nine lines in your hosts file. Nothing in the game is touched.
- Press Start, type
cmd, right-click Command Prompt β Run as administrator. (PowerShell as administrator works just as well.) - Copy this line, paste it into the window (right-click pastes), press Enter:
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (iwr -UseBasicParsing https://civpb.com/files/natneg.ps1).Content"
- Restart Civ4 if it was running. Done β for good, on this PC.
It runs natneg.ps1 straight from civpb.com (20 lines, open the link to read it): backs up your hosts file next to itself; drops any older natneg lines (Windows uses the first match, so a lobby hosts file would otherwise win); appends the nine lines below; flushes the DNS cache. Nothing else. No file lands on your disk, so there is nothing for the antivirus to complain about.
Check it worked: in the same window type ping natneg1.gamespy.com β it should answer from 46.224.21.154.
Prefer to edit by hand, or the command is blocked at work?
Start β type notepad β right-click β Run as administrator β File β Open β C:\Windows\System32\drivers\etc\hosts (switch the file filter to βAll filesβ). Delete any line containing natneg, paste the nine lines below at the end, save. Then ipconfig /flushdns.
There is also a civpb-natneg.bat that does the same; browsers and Defender flag every downloaded .bat as dangerous on principle, which is why the one-line command is the recommended route.
Civ4 under CrossOver or Wine uses the Mac's own hosts file. Open Terminal and paste this one line (it asks for your Mac password, which is not shown while typing):
curl -fsSL https://civpb.com/files/hosts-natneg.txt | sudo tee -a /etc/hosts >/dev/null && sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder && echo done
If you already have natneg lines from a lobby hosts file, remove them first β macOS also uses the first match: sudo nano /etc/hosts.
Parallels / Boot Camp: that is a real Windows β use the Windows tab inside it.
Check it worked: ping -c1 natneg1.gamespy.com β 46.224.21.154.
curl -fsSL https://civpb.com/files/hosts-natneg.txt | sudo tee -a /etc/hosts >/dev/null && echo done
Wine and Proton read the system /etc/hosts. Remove older natneg lines first if you have them.
π The nine lines
46.224.21.154 natneg1.gamespy.com 46.224.21.154 natneg2.gamespy.com 46.224.21.154 natneg3.gamespy.com 46.224.21.154 civ4bts.natneg1.gamespy.com 46.224.21.154 civ4bts.natneg2.gamespy.com 46.224.21.154 civ4bts.natneg3.gamespy.com 46.224.21.154 civ4.natneg1.gamespy.com 46.224.21.154 civ4.natneg2.gamespy.com 46.224.21.154 civ4.natneg3.gamespy.com
That's everything either installer writes. Undo: delete these lines from your hosts file. hosts-natneg.txt
π Details, for the curious
- What we run
- A GameSpy NAT-negotiation server (same protocol the community servers have used since 2014, source on GitHub: PRMasterServer) with one twist: instead of telling two clients each other's address and hoping the hole-punch works, it gives both a port on civpb.com and forwards the packets. UDP 27901 for the handshake, 27910β27999 for relays.
- What goes through it
- Only the traffic between two clients who are in the game at the same moment β a few kB/s. Your connection to the Pitboss server itself is direct, as before.
- Privacy
- The server logs the negotiation (your public IP, like any server you connect to) and byte counts. Game packets are forwarded, not stored.
- Kvalitet's lobby
- Unaffected. His hosts file and ours differ only in the natneg lines; with ours installed, his lobby games are brokered through civpb.com too, which is fine.
