Article Content
Article Number | 000031517 |
Applies To | RSA Product Set: Security Analytics RSA Version/Condition: 10.4.x, 10.5.x Platform: CentOS O/S Version: EL6 |
Tasks | Testing a list of ports can be a time consuming task. The script below saves time checking connectivity to a list of ports, and is useful to check if there is a firewall blocking connections between appliances. IPTOCHECK="192.168.12.108";for ports in $(echo -e 22 80 443 8140 61614);do timeout 5 bash -c "cat < /dev/null > /dev/tcp/$IPTOCHECK/$ports"; if [[ $? -eq 0 ]]; then echo -e "$IPTOCHECK:$ports OK" ; else echo -e "$IPTOCHECK:$ports NOK" ; fi ; done; unset IPTOCHECK Replace the value for IPTOCHECK with the IP address on which you wish to check the ports. Replace the values after echo -e with the ports you wish to check. (example uses 22 80 443 8140 61614 64000) Output: [root@rsaaio logs]# IPTOCHECK="192.168.12.108";for ports in $(echo -e 22 80 443 8140 61614 64000);do timeout 5 bash -c "cat < /dev/null > /dev/tcp/$IPTOCHECK/$ports"; if [[ $? -eq 0 ]]; then echo -e "$IPTOCHECK:$ports OK" ; else echo -e "$IPTOCHECK:$ports NOK" ; fi ; done; unset IPTOCHECK 192.168.12.108:22 OK 192.168.12.108:80 OK 192.168.12.108:443 OK 192.168.12.108:8140 OK 192.168.12.108:61614 OK bash: connect: Connection refused bash: /dev/tcp/192.168.12.108/64000: Connection refused 192.168.12.108:64000 NOK The "Connection refused" and NOK message indicates that the port is not reachable on that IP address. |