My son plays Team Fortress 2 a great deal and wanted to host his own server with mods for him and his friends to play on. Rather than using his PC for that I created an account for him on the Linux basement server.

I downloaded the Linux dedicated server, did a little port forwarding, a few small scripts with screen and POOF! he can now run and manage his own TF2 server. I need to email him some troubleshooting steps but it’s pretty basic even with SourceMods. It works.

Except I’m using FIOS and my IP addresss changes from time to time. The basement server does update it’s DNS entry via Namecheap but TF2 favorites work by IP address.

When the address changes the port forwarding still works but my son’s friends can’t find the server. The IP address changed and their favorite is gone. That sucks.

IP Tables to the rescue

I happen to have a fixed IP address on the Internet. This web server. I don’t have to run the dedicated server on my VPS, I just have to port forward TCP and UPD ports 27015 to the FIOS router.

  1. My basement server keeps the dynamic DNS name updated with the external IP address.
  2. My web server runs script every hour to see if the IP address changed for that DNS entry.
  3. If it did change then it deletes just the old iptable rules and re-add them with the new IP address.

I found a useful bash script for targeting specific rules in named sections of iptables. Why re-invent the wheel? 😉

Here’s the script.

I registered the server on Gametracker and the banner works fine.


It works and while the server’s actual IP address changes this will let others find my server. I only change my web server’s host once every few years so this will remain in place for a long time.

They like Minecraft maps. I don’t know why but that’s alright.