linux / mac os ping 指定端口号

centos 上我们可以直接用telnet进行连接,测试是否可以

如果没有telnet命令,可以使用yum 先安装telnet

yum install telnet

[root@VM_0_14_centos /]# telnet localhost 80

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

macos 下面使用一下命令

van@van ~$ nc -vz -w 2 94.19.**.218 80

found 0 associations

found 1 connections:

 1: flags=82

outif en0

src 192.168.10.51 port 59344

dst 94.191.120.218 port 80

rank info not available

TCP aux info available

Connection to 94.19.**.218 port 80 [tcp/http] succeeded!

van@van ~$ nc -help

usage: nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval] [-p source_port] [--apple-delegate-pid pid] [--apple-delegate-uuid uuid]

 [-s source_ip_address] [-w timeout] [-X proxy_version]

 [-x proxy_address[:port]] [hostname] [port[s]]

Command Summary:

-4 Use IPv4

-6 Use IPv6

-A Set SO_RECV_ANYIF on socket

-a Set SO_AWDL_UNRESTRICTED on socket

-b ifbound Bind socket to interface

-c Send CRLF as line-ending

-C Don't use cellular connection

-D Enable the debug socket option

-d Detach from stdin

-E Don't use expensive interfaces

-F Do not use flow advisory (flow adv enabled by default)

-G conntimo Connection timeout in seconds

-h This help text

-H keepidle Initial idle timeout in seconds

-I keepintvl Interval for repeating idle timeouts in seconds

-i secs Delay interval for lines sent, ports scanned

-J keepcnt Number of times to repeat idle timeout

-k Keep inbound sockets open for multiple connects

-K tclass Specify traffic class

-l Listen mode, for inbound connects

-L num_probes Number of probes to send before generating a read timeout event

-m Set SO_INTCOPROC_ALLOW on socket

-n Suppress name/port resolutions

-M Use MULTIPATH domain socket

-N num_probes Number of probes to send before generating a write timeout event

-O Use old-style connect instead of connectx

-p port Specify local port for remote connects (cannot use with -l)

-r Randomize remote ports

-s addr Local source address

-t Answer TELNET negotiation

-U Use UNIX domain socket

-u UDP mode

-v Verbose

-w secs Timeout for connects and final net reads

-X proto Proxy protocol: "4", "5" (SOCKS) or "connect"

-x addr[:port] Specify proxy address and port

-z Zero-I/O mode [used for scanning]

-o Issue socket options after connect/bind

--apple-delegate-pid pid Set socket as delegate using pid

Port numbers can be individual or ranges: lo-hi [inclusive]

来自:linux / mac os ping 指定端口号

你可能感兴趣的:(linux / mac os ping 指定端口号)