1. echo 1 > /proc/sys/net/ipv4/ip_forward

2. 在NAT服务器上添加以下规则:

PREROUTING链中添加目的地址转换规则:
iptables -t nat -I PREROUTING -i eth0 -p tcp --dpor 53 -j DNAT --to-destination 202.96.134.130

iptables -t nat -I PREROUTING -i eth0 -p udp --dpor 53 -j DNAT --to-destination 202.96.134.130

POSTROUTING链中添加源地址转换规则:
iptables -t nat -I POSTROUTING -o eth1 -s 192.168.52.0/24 -p tcp --dpor 53 -j SNAT --to-source 202.96.134.10:40000-50000

iptables -t nat -I POSTROUTING -o eth1 -s 192.168.52.0/24 -p udp --dpor 53 -j SNAT --to-source 202.96.134.10:40000-50000

3. 测试

在内部网任一台计算机上,将DNS设置为任意的外网IP,就可以使用DNS测试工具如nslookup来解析DNS服务器202.96.134.130上的名称.

相关文章:

  • 2021-12-14
  • 2021-10-22
  • 2021-08-05
  • 2022-12-23
  • 2021-06-28
  • 2022-02-04
  • 2022-12-23
  • 2017-12-05
猜你喜欢
  • 2021-05-17
  • 2022-01-18
  • 2022-12-23
  • 2021-10-06
  • 2021-06-09
相关资源
相似解决方案