Linux nc command
The Linux nc command is used to configure routers.
Executing this command can set the relevant parameters of the router.
Syntax
nc [-hlnruz][-g<网关...>][-G<指向器数目>][-i<延迟秒数>][-o<输出文件>][-p<通信端口>][-s<来源位址>][-v...][-w<超时秒数>][主机名称][通信端口...]
Parameter Description:
- -g
Set the router's hop communication gateways; up to 8 can be set. - -G
Set the source route routers; the value must be a multiple of 4. - -h Online help.
- -i
Set the time interval for transmitting information and scanning communication ports. - -l Use listen mode to manage incoming data.
- -n Use IP addresses directly instead of going through a domain name server.
- -o
- -p
Set the communication port used by the local host. - -r Randomly assign the communication ports of the local and remote hosts.
- -s
Set the IP address from which the local host sends packets. - -u Use the UDP transport protocol.
- -v Display the command execution process.
- -w
Set the time to wait for a connection. - -z Use zero input/output mode; only used when scanning communication ports.
Example
TCP port scanning
# 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
Scan UDP ports
# nc -u -z -w2 192.168.0.1 1-1000 //Scanning ports of 192.168.0.3, range is 1-1000
Scan specific ports
# nc -nvv 192.168.0.1 80 //scan port 80
(UNKNOWN) [192.168.0.1] 80 (?) open
y //用户输入
Linux Command Reference