使用nc测试服务器UDP端口

来源:互联网 发布:第六届网络复活赛 编辑:程序博客网 时间:2024/06/05 18:57

背景:自己买了台阿里云公有云服务器,准备在上面搭建L2TP ipsec vpn服务器,vpn服务搭建号后拨号连接失败。ipsec服务有用到500和4500的UDP端口,xl2tpd服务有用到1701tcp端口。然后就想着是不是端口没有开放,查看了阿里云安全策略组,如下图没有开放这些端口。
这里写图片描述

现在使用nc进行测试udp端口是否通常。在服务器安装nc服务:yum install -y nc;

a端:nc -ul 500(500为测试的端口)
b端:nc -u x.x.x.x 500(x.x.x.x为测试服务器地址)

正常情况下在b端输入字符串可以在a端接受到。

以下为nc其他具体用法:
[root@iZbp11xxgd5xknn770pxecZ ~]# 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 Enable the TCP MD5 signature option
-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]

原创粉丝点击