Total Pageviews

Monday, 21 December 2015

用nc检测端口是否正常

nc -uz 10.168.101.35 161
Connection to 10.168.101.35 161 port [udp/snmp] succeeded!
公有IP (A):
// 服务器端起UDP 27000端口
[ec2-user@ip-172-31-9-71 ~]$ sudo nc -l -k -u 27000
123
abc
^C[ec2-user@ip-172-31-9-71 ~]$
// 客户端连接正常
[ec2-user@ip-172-31-7-182 ~]$ nc -u A 27000
123
abc
^C
[ec2-user@ip-172-31-7-182 ~]$
加上EIP (B)后再测试:
// 服务器端起UDP 27000端口
[ec2-user@ip-172-31-7-182 ~]$ sudo nc -l -u 27000 nc -u B 27000
xyz
^C
// 客户端连接正常
[ec2-user@ip-172-31-9-71 ~]$ nc -u B 27000
xyz