很多人想优化自己的freebsd,特别是在网络性能以及内核调整上,因为这些是最直接的优化方式。在这里我收集整理并用中文注释了一下,相信很多人用得到。
code
#最大的待发送tcp数据缓冲区空间
.net..net.tcp.sendspace=65536
#最大的接受tcp缓冲区空间
.net..net.tcp.recvspace=65536
#最大的接受udp缓冲区大小
.net..net.udp.sendspace=65535
#最大的发送udp数据缓冲区大小
.net..net.udp.maxdgram=65535
#本地套接字连接的数据发送空间
.net.local.stream.sendspace=65535
#加快网络性能的协议
.net..net.tcp.rfc1323=1
.net..net.tcp.rfc1644=1
.net..net.tcp.rfc3042=1
.net..net.tcp.rfc3390=1
#最大的套接字缓冲区
kern.ipc.maxsockbuf=2097152
#系统中允许的最多文件数量
kern.maxfiles=65536
#每个进程能够同时打开的最大文件数量
kern.maxfilesperproc=32768
#当一台计算机发起tcp连接请求时,系统会回应ack应答数据包。
#该选项设置是否延迟ack应答数据包,把它和包含数据的数据包一起发送,
#在高速网络和低负载的情况下会略微提高性能,但在网络连接较差的时候,
#对方计算机得不到应答会持续发起连接请求,反而会降低性能。
.net..net.tcp.delayed_ack=0
#屏蔽icmp重定向功能
.net..net.icmp.drop_redirect=1
.net..net.icmp.log_redirect=1
.net..net.ip.redirect=0
.net..net6.ip6.redirect=0
#防止icmp广播风暴
.net..net.icmp.bmcastecho=0
.net..net.icmp.maskrepl=0
#限制系统发送icmp速率
.net..net.icmp.icmplim=100
#安全参数,编译内核的时候加了options tcp_drop_synfin才可以用
.net..net.icmp.icmplim_output=0
.net..net.tcp.drop_synfin=1
#设置为1会帮助系统清除没有正常断开的tcp连接,这增加了一些网络带宽的使用,但是一些死掉的连接最终能被识别并清除。死的tcp连接是被拨号用户存取的系统的一个特别的问题,因为用户经常断开modem而不正确的关闭活动的连接
.net..net.tcp.always_keepalive=1
#若看.net..net.ip.intr_queue_drops这个在增加,就要调.net..net.ip.intr_queue_maxlen,为0最好
.net..net.ip.intr_queue_maxlen=1000
#防止dos攻击,默认为30000
.net..net.tcp.msl=7500
#接收到一个已经关闭的端口发来的所有包,直接drop,如果设置为1则是只针对tcp包
.net..net.tcp.blackhole=2
#接收到一个已经关闭的端口发来的所有udp包直接drop
.net..net.udp.blackhole=1
#为网络数据连接时提供缓冲
.net..net.tcp.inflight.enable=1
#如果打开的话每个目标地址一次转发成功以后它的数据都将被记录进路由表和arp数据表,节约路由的计算时间,但会需要大量的内核内存空间来保存路由表
.net..net.ip.fastforwarding=0
##kernel编译打开options polling功能,高负载情况下使用低负载不推荐
##smp不能和polling一起用
#kern.polling.enable=1
#并发连接数,默认为128,推荐在1024-4096之间,数字越大占用内存也越大
kern.ipc.somaxconn=32768
#禁止用户查看其他用户的进程
security.bsd.see_other_uids=0
#设置kernel安全级别
kern.securelevel=0
#记录下任何tcp连接
.net..net.tcp.log_in_vain=1
#记录下任何udp连接
.net..net.udp.log_in_vain=1
#防止不正确的udp包的攻击
.net..net.udp.checksum=1
#防止dos攻击
.net..net.tcp.syncookies=1
#仅为线程提供物理内存支持,需要256兆以上内存
kern.ipc.shm_use_phys=1
# 线程可使用的最大共享内存
kern.ipc.shmmax=67108864
# 最大线程数量
kern.ipc.shmall=32768
# 程序崩溃时不记录
kern.coredump=0
# lo本地数据流接收和发送空间
.net.local.stream.recvspace=65536
.net.local.dgram.maxdgram=16384
.net.local.dgram.recvspace=65536
# 数据包数据段大小,adsl为1452。
.net..net.tcp.mssdflt=1460
# 为网络数据连接时提供缓冲
.net..net.tcp.inflight_enable=1
# 数据包数据段最小值,adsl为1452
.net..net.tcp.minmss=1460
# 本地数据最大数量
.net..net.raw.maxdgram=65536
# 本地数据流接收空间
.net..net.raw.recvspace=65536
#ipfw防火墙动态规则数量,默认为4096,增大该值可以防止某些病毒发送大量tcp连接,导致不能建立正常连接
.net..net.ip.fw.dyn_max=65535
#设置ipf防火墙tcp连接空闲保留时间,默认8640000(120小时)
.net..net.ipf.fr_tcpidletimeout=864000
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器