ubuntu 16.04 strongswan vpn配置时注意事项(连接成功,但不能上网问题)

ubuntu 16.04 strongswan vpn配置时注意事项

参考链接

https://raymii.org/s/tutorials/IPSEC_vpn_with_Ubuntu_16.04.html

这个教程确实很好,但是配置完成后不能上网,请按下面的操作进行操作;

注意事项

参照上述文章,确实是可以实现strongswan配置的,但配置完成后,上不了网,是由于其iptables配置不正确 ,请按照下面的规则进行配置;
请确认iptables是空的,没有任何规则;

# keep connect , accept 22 for ssh
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# accept local 
iptables -A INPUT -i lo -j ACCEPT

# accept ipsec 
iptables -A INPUT -p udp --dport 500 --j ACCEPT
iptables -A INPUT -p udp --dport 4500 --j ACCEPT
iptables -A INPUT -p esp -j ACCEPT

iptables -A FORWARD --match policy --pol ipsec --dir in  --proto esp -s 10.42.42.0/24 -j ACCEPT
iptables -A FORWARD --match policy --pol ipsec --dir out --proto esp -d 10.42.42.0/24 -j ACCEPT

iptables -t nat -A POSTROUTING -s 10.42.42.0/24 -o eth0 -m policy --pol ipsec --dir out -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.42.42.0/24 -o eth0 -j MASQUERADE

iptables -t mangle -A FORWARD --match policy --pol ipsec --dir in -s 10.42.42.0/24 -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1361:1536 -j TCPMSS --set-mss 1360


iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP

猜你喜欢

转载自blog.csdn.net/fick777/article/details/79248407