Linux nc Command
The Linux nc command is used to set up routers.
This command allows you to configure the relevant parameters of routers.
Syntax
nc [-hlnruz][-g<gateway...>][-G<pointer count>][-i<delay seconds>][-o<output file>][-p<communication port>][-s<source address>][-v...][-w<timeout seconds>][hostname][communication port...]
Parameter Description:
-g<gateway> Set the router hop communication gateway, up to 8 can be set.
-G<pointer count> Set the source route pointer, the value should be a multiple of 4.
-h Online help.
-i<delay seconds> Set the time interval for sending messages and scanning communication ports.
-l Use listen mode, control incoming data.
-n Directly use IP addresses without going through the domain name server.
-o<output file> Specify a file name to dump the transmitted data in hexadecimal code.
-p<communication port> Set the communication port used by the local host.
-r Randomly specify the communication ports for the local and remote hosts.
-s<source address> Set the IP address of the data packet sent by the local host.
-u Use the UDP transmission protocol.
-v Display the command execution process.
-w<timeout seconds> Set the waiting time for connection.
-z Use 0 input/output mode, only used for scanning communication ports.
Examples
TCP Port Scan
# nc -v -z -w2 192.168.0.3 1-100
192.168.0.3: inverse host lookup failed: Unknown host
(UNKNOWN) [192.168.0.3] 80 (http) open
(UNKNOWN) [192.168.0.3] 23 (telnet) open
(UNKNOWN) [192.168.0.3] 22 (ssh) open
Scan ports 1-100 on 192.168.0.3
UDP Port Scan
# nc -u -z -w2 192.168.0.1 1-1000 //Scan ports 1-1000 on 192.168.0.3
Scan Specific Port
# nc -nvv 192.168.0.1 80 //Scan port 80
(UNKNOWN) [192.168.0.1] 80 (?) open
y //User input