您的位置:首页 > 大数据 > 人工智能

使用nc检测udp端口是否可以正常通讯

2012-09-17 19:55 766 查看
netcat,很少用,总把这东西忘了,做个记录,这玩意也有windows版的http://joncraton.org/blog/46

[root@domU-12-33-39-01-6C-F1:~] nc -h

usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]

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

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

        Command Summary:

                -4              Use
IPv4

                -6              Use
IPv6

                -D              Enable
the debug socket option

                -d              Detach
from stdin

                -h              This
help text

                -i secs         Delay
interval for lines sent, ports scanned

                -k              Keep
inbound sockets open for multiple connects

                -l              Listen
mode, for inbound connects

                -n              Suppress
name/port resolutions

                -p port         Specify
local port for remote connects

                -r              Randomize
remote ports

                -s addr         Local
source address

                -T ToS          Set
IP Type of Service

                -C              Send
CRLF as line-ending

                -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]

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

用来测试upd端口是否正常

a端:nc -ul 161

b端: nc -u a.a.a.a 161

在b端随便输入字符,看是否能够传到a端。 

通过测试,使用nc传文件要比scp快不少,当然,安全性低了。

a端:nc -l 161 >/opt/test

b端:nc a.a.a.a 161 <test

不要使用udp协议啊,UDP不保证传输的可靠性
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息