1. 使用工具
- nc(netcat)
- socat(netcat的加强版)
2. 参考文章
https://icode.best/i/03548747279864
https://stackoverflow.com/questions/13294893/broadcasting-a-message-using-nc-netcat
https://www.daimajiaoliu.com/daima/487231fe51003fc
http://brieflyx.me/2015/linux-tools/socat-introduction/
https://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
https://www.hi-linux.com/posts/61543.html#vip-container
3. 工具安装
socat:
yum install -y socat
4. 测试
nc
host: nc -lu 0.0.0.0 9999
client:
echo "hello" | nc -u 172.30.59.85 9999
echo "hello" | nc -u 255.255.255.255 9999
socat
host:
nc -lu 0.0.0.0 9999
client:
echo -n "message\r\n" | socat - udp-datagram:172.0.0.255:9999,broadcast
echo -n "message\r\n" | socat - udp-datagram:172.30.59.85:9999,broadcast
5. 结论
vSwitch内网环境无法进行udp广播,官方证明如下:
http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/pdf/vpc-product-introduction-intl-zh-2017-02-06.pdf