问题描述:
搬瓦工 centos 7 x64 最小化安装,网上原始的 ocserv 一键安装脚本直接用有问题,稍微修改了一下
在安装成功后, putty 远程连接 22222 端口和 anyconnect 连接 11111 端口都是能正常使用的
但是重启后,以上两种都无法连接上了
按理说脚本里也有 systemctl restart iptables.service ,应该和系统重启对规则的影响是一样的吧
linux 新手不太懂,是不是防火墙的规则有问题?
参考:
一键安装脚本里的 iptables 修改
elif [[ ${iptablesisactive} = 'active' ]]; then
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i venet0 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p udp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp --dport 22222-j ACCEPT
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
iptables -I INPUT -p tcp --dport 11111 -j ACCEPT
iptables -I INPUT -p udp --dport 11111 -j ACCEPT
iptables -I FORWARD -s ${vpnnetwork} -j ACCEPT
iptables -t nat -A POSTROUTING -s ${vpnnetwork} -o venet0 -j MASQUERADE
# iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -P OUTPUT ACCEPT
service iptables save
systemctl restart iptables.service
通过搬瓦工后台 iptables -L 查看现在的所有规则
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:11111
ACCEPT tcp -- anywhere anywhere tcp dpt:11111
ACCEPT udp -- anywhere anywhere udp dpt:https
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:webcache
ACCEPT tcp -- anywhere anywhere tcp dpt:22222
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 192.168.8.0/24 anywhere
TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
搬瓦工 centos 7 x64 最小化安装,网上原始的 ocserv 一键安装脚本直接用有问题,稍微修改了一下
在安装成功后, putty 远程连接 22222 端口和 anyconnect 连接 11111 端口都是能正常使用的
但是重启后,以上两种都无法连接上了
按理说脚本里也有 systemctl restart iptables.service ,应该和系统重启对规则的影响是一样的吧
linux 新手不太懂,是不是防火墙的规则有问题?
参考:
一键安装脚本里的 iptables 修改
elif [[ ${iptablesisactive} = 'active' ]]; then
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i venet0 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p udp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp --dport 22222-j ACCEPT
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
iptables -I INPUT -p tcp --dport 11111 -j ACCEPT
iptables -I INPUT -p udp --dport 11111 -j ACCEPT
iptables -I FORWARD -s ${vpnnetwork} -j ACCEPT
iptables -t nat -A POSTROUTING -s ${vpnnetwork} -o venet0 -j MASQUERADE
# iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -P OUTPUT ACCEPT
service iptables save
systemctl restart iptables.service
通过搬瓦工后台 iptables -L 查看现在的所有规则
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:11111
ACCEPT tcp -- anywhere anywhere tcp dpt:11111
ACCEPT udp -- anywhere anywhere udp dpt:https
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:webcache
ACCEPT tcp -- anywhere anywhere tcp dpt:22222
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 192.168.8.0/24 anywhere
TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
Chain OUTPUT (policy ACCEPT)
target prot opt source destination