Thursday, November 21, 2013

Continuously keep trying a connection

To send continuous packets to a port on a server
useful for when your are tracing packets to troubleshoot a VPN or connection problem.

The following will keep retrying

 while true; do nc <ip address of server> <port>;done 

eg

 while true; do nc 192.168.0.1 8080;done 
or if you prefer telnet over netcat

while true; do telnet 192.168.0.1 8080;done 

can also be used to keep retrying your ssh connection until it connects.
eg
while true; do ssh user@192.168.0.1 ;done