Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

Bash

Test Tcp Open Port

If you don't have telnet or nc installed and want to quickly test firewall traffic to a server and specific port you can try this. It needs a new enough bash but still pretty quick and handy.

Good test port is open

$ timeout 1 bash -c 'cat < /dev/null > /dev/tcp/172.18.10.66/1521'
$ echo $?
0

Port not open

$ timeout 1 bash -c 'cat < /dev/null > /dev/tcp/172.18.10.66/15'
$ echo $?
124

Good test port is open to google FQDN

$ timeout 1 bash -c 'cat < /dev/null > /dev/tcp/google.com/80'
[opc@ocilxeasdbt02 ~]$ echo $?
0

admin

Bio Info for Riaan