Telnet 测试 UDP 端口?

Telnet 并不支持 UDP 端口的测试,可以使用 nc 命令来进行测试。nc 命令两种都支持:

TCP

# nc -z -v -u [hostname/IP address] [port number] 

 

# nc -z -v 192.168.10.12 22 

Connection to 192.118.20.95 22 port [tcp/ssh] succeeded!

UDP

# nc -z -v [hostname/IP address] [port number] 

 

# nc -z -v -u 192.168.10.12 123 

Connection to 192.118.20.95 123 port [udp/ntp] succeeded!

下面是一些 nc 的简单用例:


  - Start a listener on the specified TCP port and send a file into it:
    nc -l -p port < filename

  - Connect to a target listener on the specified port and receive a file from it:
    nc host port > received_filename

  - Scan the open TCP ports of a specified host:
    nc -v -z -w timeout_in_seconds host start_port-end_port

  - Start a listener on the specified TCP port and provide your local shell access to the connected party (this is dangerous and can be abused):
    nc -l -p port -e shell_executable

  - Connect to a target listener and provide your local shell access to the remote party (this is dangerous and can be abused):
    nc host port -e shell_executable

  - Act as a proxy and forward data from a local TCP port to the given remote host:
    nc -l -p local_port | nc host remote_port

  - Send an HTTP GET request:
    echo -e "GET / HTTP/1.1\nHost: host\n\n" | nc host 80

Telnet 是一种用于测试 TCP 连接的工具,不能直接用于测试 UDP 端口。但是,你可以使用其他工具来测试 UDP 端口的可用性,例如使用 `nc`(netcat)命令或使用 `nmap` 工具。 使用 `nc` 命令可以简单地检查 UDP 端口是否开放。以下是使用 `nc` 命令检测 UDP 端口的步骤: 1. 打开终端或命令提示符。 2. 运行以下命令来测试 UDP 端口: ``` nc -u -zv <主机名或IP地址> <端口号> ``` 替换 `<主机名或IP地址>` 和 `<端口号>` 为你要测试的实际值。 例如,要测试主机名为 `example.com` 的 UDP 端口 1234,命令将如下所示: ``` nc -u -zv example.com 1234 ``` 如果 UDP 端口开放,则将显示类似以下内容的输出: ``` Connection to example.com 1234 port [udp/*] succeeded! ``` 如果 UDP 端口关闭或不可访问,则将显示类似以下内容的输出: ``` nc: connect to example.com port 1234 (udp) failed: Connection refused ``` 使用 `nmap` 工具也可以检测 UDP 端口的可用性。以下是使用 `nmap` 工具检测 UDP 端口的步骤: 1. 打开终端或命令提示符。 2. 运行以下命令来测试 UDP 端口: ``` nmap -sU -p <端口号> <主机名或IP地址> ``` 替换 `<主机名或IP地址>` 和 `<端口号>` 为你要测试的实际值。 例如,要测试主机名为 `example.com` 的 UDP 端口 1234,命令将如下所示: ``` nmap -sU -p 1234 example.com ``` `nmap` 将扫描指定的 UDP 端口,并显示端口的状态。开放的端口将显示为 "open",关闭的端口将显示为 "closed"。 请注意,使用这些工具测试 UDP 端口时,需要确保防火墙或网络设备允许 UDP 流量通过。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值