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 請求 ntp 到 192.168.10.1,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設定檔。

相關內容