Introduction
nc is shorthand for ncat/netcat command. In a minimal installation of CentOS 7 / RHEL 7, nc is not installed by default. It needs to be installed manually with the following command.
[root@localhost ~]# yum install nmap-ncat -y
Function
- Realize the listening of any TCP/UDP port, nc can be used as a server to listen to the scanning of specified
ports , and nc can be used as a client to initiate TCP or UDP connections - Transfer files between machines
- Network speed test between machines
grammar
ncat [options] [hostname] [port]
Options
- -l Turn on listen mode, which is used to specify that nc will be in listen mode. Specifying this parameter means that nc is treated as a server, listening for and accepting connections, rather than initiating connections to other addresses.
- -p is not used yet (the old version of nc may need to add the -p parameter before the port number, the following test environment is centos6.6, the nc version is nc-1.84, the -p parameter is not used)
- -s specifies the source IP address for sending data, suitable for multi-NIC machines
- -u specifies that nc uses the UDP protocol, the default is TCP
- -v Output interactive or error messages, especially useful for novice debugging
- -w timeout in seconds, followed by a number
- -c execute command