How to test network access without telnet or netcat

If you want to check a TCP connection with an specifif host, instead of using telnet or netcat, you can use echo. It’s really simple. Try this:

$ echo "" > /dev/tcp/www.facebook.com/443 && echo "Success"
Success

If the commands returns Success you have access. If the command hangs, you can use Ctrl + C to stop it and now you know you don’t have connectivity.

You can try this using a “wrong” port and then press Ctrl + C:

$ echo "" > /dev/tcp/facebook.com/444 && echo "Success"

This is quite useful when you’re dealing with containers or really small vms.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s