Questo contenuto non è disponibile nella lingua selezionata.
1.7. Managing Data Using the ncat utility
IPv4
and IPv6
, open connections, send packets, perform port scanning, and supports higher-level features such as SSL
, and connection broker.
nc
command can also be entered as ncat
, using the identical options. For more information about the ncat options, see the New networking utility (ncat) section in the Migration Planning Guide and the ncat(1) man page.
Installing ncat
root
:
~]# yum install ncat
~]# yum install ncat
Brief Selection of ncat Use Cases
Example 1.1. Enabling Communication between a Client and a Server
- Set a client machine to listen for connections on TCP port 8080:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ncat -l 8080
~]$ ncat -l 8080
- On a server machine, specify the IP address of the client and use the same port number:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ncat 10.0.11.60 8080
~]$ ncat 10.0.11.60 8080
You can send messages on either side of the connection and they appear on both local and remote machines. - Press
Ctrl+D
to close the TCP connection.
Note
nc
commands with the –u
option. For example:
~]$ ncat -u -l 8080
~]$ ncat -u -l 8080
Example 1.2. Sending Files
- On a client machine, to listen a specific port transferring a file to the server machine:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ncat -l 8080 > outputfile
~]$ ncat -l 8080 > outputfile
- On a server machine, specify the IP address of the client, the port and the file which is to be transferred:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ncat -l 10.0.11.60 8080 < inputfile
~]$ ncat -l 10.0.11.60 8080 < inputfile
Note
~]$ ncat -l 8080 < inputfile
~]$ ncat -l 8080 < inputfile
~]$ ncat -l 10.0.11.60 8080 > outputfile
~]$ ncat -l 10.0.11.60 8080 > outputfile
Example 1.3. Creating an HTTP proxy server
~]$ ncat -l --proxy-type http localhost 8080
~]$ ncat -l --proxy-type http localhost 8080
Example 1.4. Port Scanning
–z
option and specify a range of ports to scan:
~]$ ncat -z 10.0.11.60 80-90 Connection to 192.168.0.1 80 port [tcp/http] succeeded!
~]$ ncat -z 10.0.11.60 80-90
Connection to 192.168.0.1 80 port [tcp/http] succeeded!
Example 1.5. Setting up Secure Client-Server Communication Using SSL
SSL
on a server:
~]$ ncat -e /bin/bash -k -l 8080 --ssl
~]$ ncat -e /bin/bash -k -l 8080 --ssl
~]$ ncat --ssl 10.0.11.60 8080
~]$ ncat --ssl 10.0.11.60 8080
Note
SSL
connection, the server requires the --ssl-cert
and --ssl-key
options, and the client requires the --ssl-verify
and --ssl-trustfile
options. For information on OpenSSL
, see the Using OpenSSL section in the Security Guide.