PHP: Test for open TCP ports, my ‘new’ toy.

When you’re tunneling ports behind NAT, it’s useful to know what ports you have open, and wether or not it’s working. Short of having a system outside of your firewall, there are relatively few safe ways of testing.

There are at least a few sites which offer similar utilities, however, they are usually capable of only testing a single port at a time, which is nearly impossible to use when testing a dynamic range of ports.

For this purpose, I’ve created my TCP port test utility.

Note that I’ve created a few safeguards so this system will not be abused:

  • Only ports between 1024 and 65535 are allowed to be tested.
  • A range of only 50 sequential ports are allowed to be tested at a time.
  • You are only able to test the IP that the server sees you coming from.
  • It uses a simple cookie system; if you block cookies, you won’t be able to use it.