我的意思是真正的新手 - 这里是 Linux。请帮助我通过 iptables 配置我的 openvpn。
我的主要目标是像 ISP 一样打开常规浏览 (80、443)、电子邮件 (110、25) 等端口,但我想阻止 p2p 流量。所以我只需要打开几个端口。
这是我的 iptables 配置
# Flush all current rules from iptables
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
#
# Allow SSH connections on tcp port 22 (or whatever port you want to use)
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#
# Set default policies for INPUT, FORWARD and OUTPUT chains
#
iptables -P INPUT DROP #using DROP for INPUT is not always recommended. Change to ACCEPT if you prefer.
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
#
# Set access for localhost
#
iptables -A INPUT -i lo -j ACCEPT
#
# Accept packets belonging to established and related connections
#
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#
#Accept connections on 1194 for vpn access from clients
#Take note that the rule says "UDP", and ensure that your OpenVPN server.conf says UDP too
#
iptables -A INPUT -p udp --dport 1194 -j ACCEPT
#
#Apply forwarding for OpenVPN Tunneling
#
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT #10.8.0.0 ? Check your OpenVPN server.conf to be sure
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -o venet0 -j SNAT --to-source 100.200.255.256 #Use your OpenVPN server's real external IP here
#
#Enable forwarding
#
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 26 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -L -v
但是当我连接到我的 vpn 时,我无法浏览网页,并且在 ping yahoo 等时也出现了 RTO
答案1
看起来您正在使用某人的教程中的默认设置来进行 NAT 设置。
“to-source” 显然无效,因为您不能拥有一个值 > 255 的 IPv4 区段。该值应该是您服务器的外部接口的 IP。