OK, we all know how to use PING to test connectivity to an IP address. What I need to do is something similar but test if my outbound request to a given IP Address as well as a specif port (in the present case 1775) is successful. The test should be performed preferably from the command prompt.
6 Answers
Here is a small site I made allowing to test any outgoing port. The server listens on all TCP ports available.
telnet portquiz.net XXXX

- 1,571
- 1
- 11
- 9
-
1That's interesting, but it's not quite a longterm solution, right? Although I'm guessing it's very straightforward to write the code for. – Ehtesh Choudhury Oct 17 '12 at 03:45
-
@Shurane Yes it's simple: it uses iptables to redirect all tcp ports to 80. Of course it depends on my server to be available, but I'm planning to keep it up in the long term. I'm also looking for a simple easy to type domain name to register for that. If you have any idea feel free to tell me. – Marc MAURICE Apr 10 '13 at 11:55
-
Thanks. I ordered a domain for that service so it's easier to type : portquiz.net – Marc MAURICE Jul 30 '13 at 10:58
-
Does this work with Port 25? I need to find out if my ISP is blocking outgoing connections to P25. – Chuck Le Butt Sep 22 '14 at 15:30
-
4
-
You can test outbound port 22 with `ssh git@github.com` - it should say either Permission denied (publickey) or authorization successful if you have uploaded your public key to a github account – apple16 Aug 04 '15 at 22:31
-
-
If there is a server running on the target IP/port, you could use Telnet. Any response other than "can't connect" would indicate that you were able to connect.

- 20,957
- 5
- 26
- 41
To automate the awesome service portquiz.net, I did write a bash script :
NB_CONNECTION=10
PORT_START=1
PORT_END=1000
for (( i=$PORT_START; i<=$PORT_END; i=i+NB_CONNECTION ))
do
iEnd=$((i + NB_CONNECTION))
for (( j=$i; j<$iEnd; j++ ))
do
#(curl --connect-timeout 1 "portquiz.net:$j" &> /dev/null && echo "> $j") &
(nc -w 1 -z portquiz.net "$j" &> /dev/null && echo "> $j") &
done
wait
done

- 4,410
- 27
- 21
The fastest / most efficient way I found to to this is with nmap and portquiz.net described here: http://thomasmullaly.com/2013/04/13/outgoing-port-tester/ This scans to top 1000 most used ports:
# nmap -Pn --top-ports 1000 portquiz.net
Starting Nmap 6.40 ( http://nmap.org ) at 2017-08-02 22:28 CDT
Nmap scan report for portquiz.net (178.33.250.62)
Host is up (0.072s latency).
rDNS record for 178.33.250.62: electron.positon.org
Not shown: 996 closed ports
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
443/tcp open https
8080/tcp open http-proxy
Nmap done: 1 IP address (1 host up) scanned in 4.78 seconds
To scan them all (took 6 sec instead of 5):
# nmap -Pn -p1-65535 portquiz.net

- 1,049
- 11
- 13
-
Correct me if I'm wrong, but the portquiz port 445 seems not open from outside (I followed the link). What public external service should I use to test I can connect to port 445 on Internet? – рüффп Jun 26 '20 at 07:30
The bash script example of @benjarobin for testing a sequence of ports did not work for me so I created this minimal not-really-one-line (command-line) example which writes the output of the open ports from a sequence of 1-65535 (all applicable communication ports) to a local file and suppresses all other output:
for p in $(seq 1 65535); do curl -s --connect-timeout 1 portquiz.net:$p >> ports.txt; done
Unfortunately, this takes 18.2 hours to run, because the minimum amount of connection timeout allowed integer seconds by my older version of curl is 1. If you have a curl version >=7.32.0 (type "curl -V"), you might try smaller decimal values, depending on how fast you can connect to the service. Or try a smaller port range to minimise the duration.
Furthermore, it will append to the output file ports.txt so if run multiple times, you might want to remove the file first.

- 61
- 1
- 2