centos7 not config iptables

pull/109/head
233boy 6 years ago
parent cee9bb6fb0
commit 3ecb6847e6
  1. 36
      install.sh
  2. 18
      v2ray.sh

@ -874,7 +874,8 @@ install_v2ray() {
if [[ $cmd == "apt-get" ]]; then if [[ $cmd == "apt-get" ]]; then
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin $cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin
else else
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services # $cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap
fi fi
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[ -d /etc/v2ray ] && rm -rf /etc/v2ray [ -d /etc/v2ray ] && rm -rf /etc/v2ray
@ -1151,6 +1152,7 @@ install_v2ray() {
} }
open_port() { open_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then if [[ $1 != "multiport" ]]; then
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
@ -1176,15 +1178,15 @@ open_port() {
# firewall-cmd --reload # firewall-cmd --reload
fi fi
if [[ $cmd == "apt-get" ]]; then
iptables-save >/etc/iptables.rules.v4 iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6 ip6tables-save >/etc/iptables.rules.v6
else # else
service iptables save >/dev/null 2>&1 # service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1 # service ip6tables save >/dev/null 2>&1
fi fi
} }
del_port() { del_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then if [[ $1 != "multiport" ]]; then
# if [[ $cmd == "apt-get" ]]; then # if [[ $cmd == "apt-get" ]]; then
iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
@ -1217,13 +1219,11 @@ del_port() {
# firewall-cmd --permanent --zone=public --remove-port=$ports/udp # firewall-cmd --permanent --zone=public --remove-port=$ports/udp
# fi # fi
fi fi
if [[ $cmd == "apt-get" ]]; then
iptables-save >/etc/iptables.rules.v4 iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6 ip6tables-save >/etc/iptables.rules.v6
else # else
service iptables save >/dev/null 2>&1 # service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1 # service ip6tables save >/dev/null 2>&1
fi fi
} }
@ -1373,14 +1373,14 @@ config() {
/sbin/ip6tables-restore < /etc/iptables.rules.v6 /sbin/ip6tables-restore < /etc/iptables.rules.v6
EOF EOF
chmod +x /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables
else # else
[ $(pgrep "firewall") ] && systemctl stop firewalld # [ $(pgrep "firewall") ] && systemctl stop firewalld
systemctl mask firewalld # systemctl mask firewalld
systemctl disable firewalld # systemctl disable firewalld
systemctl enable iptables # systemctl enable iptables
systemctl enable ip6tables # systemctl enable ip6tables
systemctl start iptables # systemctl start iptables
systemctl start ip6tables # systemctl start ip6tables
fi fi
[ $shadowsocks ] && open_port $ssport [ $shadowsocks ] && open_port $ssport

@ -10,7 +10,7 @@ none='\e[0m'
# Root # Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 [[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1
_version="v2.47" _version="v2.48"
cmd="apt-get" cmd="apt-get"
@ -2801,6 +2801,7 @@ uninstall_lotserver() {
} }
open_port() { open_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then if [[ $1 != "multiport" ]]; then
# if [[ $cmd == "apt-get" ]]; then # if [[ $cmd == "apt-get" ]]; then
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
@ -2832,16 +2833,16 @@ open_port() {
# firewall-cmd --reload # firewall-cmd --reload
# fi # fi
fi fi
if [[ $cmd == "apt-get" ]]; then
iptables-save >/etc/iptables.rules.v4 iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6 ip6tables-save >/etc/iptables.rules.v6
else # else
service iptables save >/dev/null 2>&1 # service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1 # service ip6tables save >/dev/null 2>&1
fi fi
} }
del_port() { del_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then if [[ $1 != "multiport" ]]; then
# if [[ $cmd == "apt-get" ]]; then # if [[ $cmd == "apt-get" ]]; then
iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
@ -2865,12 +2866,11 @@ del_port() {
# firewall-cmd --permanent --zone=public --remove-port=$ports/udp # firewall-cmd --permanent --zone=public --remove-port=$ports/udp
# fi # fi
fi fi
if [[ $cmd == "apt-get" ]]; then
iptables-save >/etc/iptables.rules.v4 iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6 ip6tables-save >/etc/iptables.rules.v6
else # else
service iptables save >/dev/null 2>&1 # service iptables save >/dev/null 2>&1
service ip6tables save >/dev/null 2>&1 # service ip6tables save >/dev/null 2>&1
fi fi
} }
update() { update() {

Loading…
Cancel
Save