WMware – netcat – testing connectivity

To check if a port is open on VM

nc -z 192.168.1.2 80
Connection to 192.168.1.72 80 port [tcp/http] succeeded! 

check if UDP port is open:

 nc -z -u 192.168.1.51 53
Connection to 192.168.1.51 53 port [udp/domain] succeeded! 

Send data between hosts:
Host 1 (192.168.1.222) set to listen mode:

nc -lp 1234

Host 2 send data to host 1

nc 192.168.1.222 1234
test 123

If the port (1234) is open the text (test 123) will be displayed in the console. This trick can be used a simple chat

The same can be used to send for example a log or a text file using this syntax:

nc 192.168.1.222 1234 < /var/log/vmkernel.log

this way content of that file will be displayed on Host 1 (if conditions specified above are met).