ncat

  https://www.linuxtechi.com/nc-ncat-command-examples-linux-systems/

 

 

Example: 1) Listen to inbound connections

Ncat can work in listen mode & we can listen for inbound connections on port number with option ‘l’. Complete command is,

$ ncat -l port_number

For example,

$ ncat -l 8080


Example: 2) Connect to a remote system

To connect to a remote system with nc, we can use the following command,

$ ncat IP_address port_number

Let’s take an example,

$ ncat 192.168.1.100 80

Example: 3) Connecting to UDP ports

By default , the nc utility makes connections only to TCP ports. But we can also make connections to UDP ports, for that we can use option ‘u’,

$ ncat -l -u 1234

Now our system will start listening a udp port ‘1234’, we can verify this using below netstat command,

 

 

Example: 8) Port forwarding via nc/ncat

We can also use NC for port forwarding with the help of option ‘c’ , syntax for accomplishing port forwarding is,

$ ncat -u -l  80 -c  'ncat -u -l 8080'

Now all the connections for port 80 will be forwarded to port 8080

 

Example: 9) Set Connection timeouts

Listener mode in ncat will continue to run & would have to be terminated manually. But we can configure timeouts with option ‘w’,

$ ncat -w 10 192.168.1.100 8080

This will cause connection to be terminated in 10 seconds, but it can only be used on client side & not on server side.

posted @ 2019-10-30 19:27  anyu686  阅读(343)  评论(0编辑  收藏  举报