Centos6优化

本文介绍了一种系统级的优化配置方案,包括防火墙、SSH服务的配置调整,自启动服务的优化选择,以及系统核心参数的调整。通过禁用SELINUX、修改SSH端口和关闭DNS解析等功能增强安全性;调整系统资源限制提升性能;并删除不必要的用户和群组减少潜在的安全风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#防火墙配置
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
iptables -F
iptables -L
/etc/init.d/iptables save
#ssh配置
cp /etc/ssh/sshd_config sshd_config_bak
#sed -i '/#Port/s/22/60022/' /etc/ssh/sshd_config
#sed -i '/#Port/s/^#//' /etc/ssh/sshd_config
sed -i '/GSSAPIAuthentication/s/yes/no/' /etc/ssh/sshd_config
sed -i '/DNS/s/yes/no/' /etc/ssh/sshd_config
sed -i '/DNS/s/^#//' /etc/ssh/sshd_config
service sshd restart
#自启动服务优化
for sun in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $sun off;done
for sun in crond rsyslog sshd network iptables ip6tables;do chkconfig --level 3 $sun on;done
#系统优化
echo "* soft nofile 65535" >> /etc/security/limits.conf 
echo "* hard nofile 65535" >> /etc/security/limits.conf 
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nproc 65535" >> /etc/security/limits.conf
sed -i 's/1024/unlimited/g' /etc/security/limits.d/90-nproc.conf 

#在/etc/sysctl.conf 后面增加下面内容

echo "
#可用于apache,nginx,squid多种等web应用
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800

net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1025 65535" >> /etc/sysctl.conf

#删除不必要的用户
userdel adm
userdel lp
userdel sync
userdel shutdown
userdel halt
userdel news
userdel uucp
userdel operator
userdel games
userdel gopher
userdel ftp
#删除不必要的群组
groupdel adm
groupdel lp
groupdel news
groupdel uucp
groupdel games
groupdel dip
groupdel pppusers

 

转载于:https://my.oschina.net/caoqd/blog/1785738

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值