Iptables:将 ntp 请求从 lan 路由到内部 vpn 服务器

Iptables:将 ntp 请求从 lan 路由到内部 vpn 服务器

我必须遵循配置

   client                  gw with openvpn                 ntp server
192.168.10.82 ----> eth0 192.168.10.1 - tun0 10.8.0.46 ---> 10.8.0.1

我无法在 .82 上安装 openvpn 客户端

我希望 .82 向 192.168.10.1 请求 ntp,192.168.10.1 将通过其 tun0 接口 10.8.0.46 将问题路由到 10.8.0.1,然后再回复 .82

下面是我的 iptables 配置

# Generated by iptables-save v1.8.4 on Sun Jan  3 22:29:42 2021
*filter
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:INPUT DROP [0:0]
# Accept traffic from internal interfaces
-A INPUT ! -i eth1 -j ACCEPT
# Accept traffic with the ACK flag set
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Allow incoming data that is part of a connection we established
-A INPUT -m state --state ESTABLISHED -j ACCEPT
# Allow data that is related to existing connections
-A INPUT -m state --state RELATED -j ACCEPT
# Accept responses to DNS queries
-A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
# Accept responses to our pings
-A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
# Accept notifications of unreachable hosts
-A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
# Accept notifications to reduce sending speed
-A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT
# Accept notifications of lost packets
-A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT
# Accept notifications of protocol problems
-A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT
COMMIT
# Completed on Sun Jan  3 22:29:42 2021
# Generated by iptables-save v1.8.4 on Sun Jan  3 22:29:42 2021
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Sun Jan  3 22:29:42 2021
# Generated by iptables-save v1.8.4 on Sun Jan  3 22:29:42 2021
*nat
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]

# eth0 to 4g dongle
-A POSTROUTING -o eth1 -j MASQUERADE

尝试以下几行不起作用:

-A PREROUTING -i eth0 -p udp --dport 123 -j DNAT --to-destination 10.8.0.1:123
-A POSTROUTING -o tun0 -p udp --dport 123 -d 10.8.0.1 -j SNAT --to-source 10.8.0.46

有什么建议吗?谢谢

答案1

Tom Yan 的第一个回复是解决方案,之后的讨论是由于我的错误编辑了错误的 iptables 配置文件。

相关内容