有时候需要模拟监控TCP或者UDP的端口,幸好linux提供了好用的工具nc
yum install nc -y
监听TCP端口与测试
# 监听在tcp的3307端口
nc -lv 3307
# 往tcp的3307端口发送消息
nc localhost 3307
1564389178131
1564389166005
监听UDP端口与测试
# 监听在UDP的3307端口
nc -lvu 3307
# 往UDP端口发送消息
echo -n "hello world,UDP" >/dev/udp/localhost/3307
1564389272251
1564389283874