Skip to content

Test tcp open port

wordpress meta

title: 'Test Tcp Open Port'
date: '2018-08-15T08:44:46-05:00'
status: publish
permalink: /test-tcp-open-port
author: admin
excerpt: ''
type: post
id: 1259
category:
    - Bash
tag: []
post_format: []

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