小编Joh*_*han的帖子

如何在 nat 网关(iptables)中覆盖 dns 服务器

我有一台运行 openvpn 的 Ubuntu 服务器,iptables 用于通过 vpn 服务器推送所有传入流量。IP 表配置非常基础,使用以下一系列命令生成:

sudo iptables --flush
sudo iptables --table nat --flush
sudo iptables --delete-chain
sudo iptables --table nat --delete-chain
sudo iptables --table nat --append POSTROUTING --out-interface tun0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface eth0 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

我一直在尝试通过添加以下两行来重写流量以强制使用特定的 dns 服务器:

sudo iptables --table nat --append PREROUTING -i eth0 -p tcp --sport 53 -j DNAT --to-destination 146.148.119.121:53
sudo iptables --table nat --append PREROUTING -i eth0 -p udp --sport 53 -j DNAT --to-destination 146.148.119.121:53
Run Code Online (Sandbox Code Playgroud)

但它不工作我所希望的(输出nslookup …

dns iptables openvpn nat rewrite

5
推荐指数
1
解决办法
1202
查看次数

标签 统计

dns ×1

iptables ×1

nat ×1

openvpn ×1

rewrite ×1