重新编译内核
到/sys/i386/conf里面,cp GENERIC onlinecq,再vi onlinecq优化内核,注意加入下面的内容
#disable ctrl+alt+delete
options SC_DISABLE_REBOOT
#quota limit
options QUOTA
#ipfw support
options IPFIREWALL
options DUMMYNET
options HZ=3000
options IPDIVERT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPSTEALTH
options TCP_DROP_SYNFIN
options IPFIREWALL_DEFAULT_TO_ACCEPT
options ICMP_BANDLIM
options ACCEPT_FILTER_DATA
options ACCEPT_FILTER_HTTP
#ipfilter support
#options IPFILTER
#options IPFILTER_LOG
#options IPFILTER_DEFAULT_BLOCK
再执行:
/usr/sbin/config onlinecq
cd ../../compile/onlinecq
make depend
make
make install
重新启动服务器
到此为止,服务器操作系统及内核升级成功
reboot
优化FREEBSD
检查升级情况
使用ssh进入系统,使用uname –a 可以查到是否升级成功﹔
打开防火墙
更新rc.conf里面的设置,加上:
#enable_quotas="YES"
#check_quotas="YES"
firewall_enable="YES"
firewall_script="/etc/rc.firewall"
firewall_type="/etc/ipfw.rules" #create it!
firewall_quiet="NO"
firewall_logging_enable="YES"
log_in_vain="NO"
tcp_drop_synfin="NO"
tcp_restrict_rst="YES"
icmp_drop_redirect="YES"
优化内核参数
修改系统内核参数,实现微调:vi /etc/sysctl.conf
kern.ipc.somaxconn=8192
kern.ipc.maxsockbuf=2097152
kern.maxfilesperproc=32768
kern.maxfiles=65536
kern.securelevel=-1
net.inet.tcp.sendspace=65536
net.inet.tcp.recvspace=32768
net.inet.udp.maxdgram=57344
net.inet.icmp.drop_redirect=1
net.inet.icmp.log_redirect=0
net.inet.ip.redirect=0
net.inet6.ip6.redirect=0
net.inet.icmp.icmplim=100
net.inet.tcp.always_keepalive=0
net.inet.tcp.delayed_ack=0
net.inet.tcp.log_in_vain=0
net.inet.udp.log_in_vain=0
net.inet.tcp.blackhole=2
net.inet.udp.blackhole=1
net.local.stream.sendspace=65535
net.local.stream.recvspace=32768
net.inet.ip.fastforwarding=1
vfs.vmiodirenable=1
安装防火墙
防火墙在上面已经编译入了内核,并且在上面的rc.conf里面已经打开了,所以在此只要设置一下即可!
允许所有IP通过,免得把自己给挡在外面了。
ipfw add all from any to any
其它规则根据实际情况来做,如果您想系统每次启动都使用上一次的规则,可以把这些内容加到:
vi /etc/ipfw.rules
里面,语法规则同ipfw。