|
@@ -10,9 +10,9 @@
|
|
|
|
|
|
# closed Unnecessary services and remove obsolete rpm package
|
|
|
[ "${CentOS_RHEL_version}" == '7' ] && [ "$(systemctl is-active NetworkManager.service)" == 'active' ] && NM_flag=1
|
|
|
-for Service in $(chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager');do chkconfig --level 3 ${Service} off;done
|
|
|
+for Service in $(chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager|iptables');do chkconfig --level 3 ${Service} off;done
|
|
|
[ "${NM_flag}" == '1' ] && systemctl enable NetworkManager.service
|
|
|
-for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog;do chkconfig --level 3 ${Service} on;done
|
|
|
+for Service in sshd network crond messagebus irqbalance syslog rsyslog;do chkconfig --level 3 ${Service} on;done
|
|
|
|
|
|
# Close SELINUX
|
|
|
setenforce 0
|
|
@@ -72,7 +72,7 @@ echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf
|
|
|
[ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk}
|
|
|
cat > /etc/sysctl.conf << EOF
|
|
|
fs.file-max=65535
|
|
|
-net.ipv4.tcp_max_tw_buckets = 60000
|
|
|
+net.ipv4.tcp_max_tw_buckets = 6000
|
|
|
net.ipv4.tcp_sack = 1
|
|
|
net.ipv4.tcp_window_scaling = 1
|
|
|
net.ipv4.tcp_rmem = 4096 87380 4194304
|
|
@@ -120,15 +120,16 @@ ntpdate pool.ntp.org
|
|
|
[ ! -e "/var/spool/cron/root" -o -z "$(grep 'ntpdate' /var/spool/cron/root)" ] && { echo "*/20 * * * * $(which ntpdate) pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root;chmod 600 /var/spool/cron/root; }
|
|
|
|
|
|
# iptables
|
|
|
-if [ -e "/etc/sysconfig/iptables" ] && [ -n "$(grep '^:INPUT DROP' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables)" ]; then
|
|
|
- IPTABLES_STATUS=yes
|
|
|
-else
|
|
|
- IPTABLES_STATUS=no
|
|
|
-fi
|
|
|
-
|
|
|
-if [ "$IPTABLES_STATUS" == "no" ]; then
|
|
|
- [ -e "/etc/sysconfig/iptables" ] && /bin/mv /etc/sysconfig/iptables{,_bk}
|
|
|
- cat > /etc/sysconfig/iptables << EOF
|
|
|
+if [ "$iptables_yn" == 'y' ]; then
|
|
|
+ if [ -e "/etc/sysconfig/iptables" ] && [ -n "$(grep '^:INPUT DROP' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables)" -a -n "$(grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables)" ]; then
|
|
|
+ IPTABLES_STATUS=yes
|
|
|
+ else
|
|
|
+ IPTABLES_STATUS=no
|
|
|
+ fi
|
|
|
+
|
|
|
+ if [ "$IPTABLES_STATUS" == "no" ]; then
|
|
|
+ [ -e "/etc/sysconfig/iptables" ] && /bin/mv /etc/sysconfig/iptables{,_bk}
|
|
|
+ cat > /etc/sysconfig/iptables << EOF
|
|
|
# Firewall configuration written by system-config-securitylevel
|
|
|
# Manual customization of this file is not recommended.
|
|
|
*filter
|
|
@@ -149,12 +150,14 @@ if [ "$IPTABLES_STATUS" == "no" ]; then
|
|
|
-A syn-flood -j REJECT --reject-with icmp-port-unreachable
|
|
|
COMMIT
|
|
|
EOF
|
|
|
-fi
|
|
|
+ fi
|
|
|
|
|
|
-FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/sysconfig/iptables)
|
|
|
-[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/sysconfig/iptables
|
|
|
+ FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/sysconfig/iptables)
|
|
|
+ [ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/sysconfig/iptables
|
|
|
+ chkconfig --level 3 iptables on
|
|
|
+ service iptables restart
|
|
|
+fi
|
|
|
service rsyslog restart
|
|
|
-service iptables restart
|
|
|
service sshd restart
|
|
|
|
|
|
. /etc/profile
|