需求:
java 服务: 10.16.0.186:7000 (udp 端口)
配置的转发机器: 外网ip(1.2.3.4) 内网ip(10.16.0.95)  udp端口: 27001

iptables 开启转发功能:
echo 1 >/proc/sys/net/ipv4/ip_forward
sysctl -p

iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -p udp -m udp --dport 27001 -j DNAT --to-destination 10.16.0.186:7000 
iptables -t nat  -A POSTROUTING -d 10.16.0.186 -p udp -m udp --dport 7000 -j SNAT --to-source 10.16.0.95 

用 tcpdump udp port 27001  -n 抓包发现:
10.16.0.186 会将数据包返回至 10.16.0.95 
10.16.0.95  会将数据包返回至 客户端

数据包之间有交互就是对的

  

相关文章:

  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2021-06-09
猜你喜欢
  • 2021-12-05
  • 2021-06-02
  • 2021-12-03
  • 2021-11-25
  • 2021-10-02
相关资源
相似解决方案