你好,我有一些关于如何使用iptables转发IPsec数据的问题。以下是我想做的事:
Server1(eth0/10.81.1.2)- (eth0/10.66.2.3)Server2(eth1/WAN )-广域网
注: Server1和Server2的内部网络可以连接。
我尝试在Server1上设置这些:
iptables -t nat -A PREROUTING -p udp --dport 4500 -j DNAT --to-destination 10.66.2.3
iptables -t nat -A PREROUTING -p udp --dport 500 -j DNAT --to-destination 10.66.2.3
iptables -t nat -A PREROUTING -p udp --dport 1701 -j DNAT --to-destination 10.66.2.3
iptables -t nat -A POSTROUTING -p udp -d 10.66.2.3 --dport 4500 -j SNAT --to-source 10.81.1.2
iptables -t nat -A POSTROUTING -p udp -d 10.66.2.3 --dport 500 -j SNAT --to-source 10.81.1.2
iptables -t nat -A POSTROUTING -p udp -d 10.66.2.3 --dport 1701 -j SNAT --to-source 10.81.1.2
iptables -A FORWARD -p esp -j ACCEPT
iptables -A FORWARD -p ah -j ACCEPT但是现在我不能使用Server1 1‘S广域网IP连接到广域网计算机上的Server2 (IPsec VPN可以通过广域网直接连接到广域网计算机上的Server2 )。
我可能被误认为是某些部分,我如何设置使用Server1连接到Server2来访问广域网?
发布于 2019-10-03 13:02:58
我建议你这么做
eth0是您的“公共接口”
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE主动路由
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward将nat设置为将请求重定向到内部ipsec服务器
/sbin/iptables -t nat -A PREROUTING -i eth0 -p utp --dport 1701 -j DNAT --to-destination 10.66.2.3:1701
/sbin/iptables -t nat -A PREROUTING -i eth0 -p utp --dport 500 -j DNAT --to-destination 10.66.2.3:500
/sbin/iptables -t nat -A PREROUTING -i eth0 -p utp --dport 4500 -j DNAT --to-destination 10.66.2.3:4500发布于 2018-07-11 18:33:17
你的iptables设置看起来不错。您是否启用了server1上的ip转发?(默认情况下已禁用)
echo 1 > /proc/sys/net/ipv4/ip_forwardhttps://serverfault.com/questions/918970
复制相似问题