建立一個文件夾把驅(qū)動復(fù)制到里面 
#mkdir /usr/local/src/em 
解壓縮 
#tar xvfz em-5.1.5.tar.gz 
#cd em-5.1.5 
編譯模塊 
# make 
安裝編譯好的模塊 
#make install 
如果你想啟動的時候自動加載模塊修改 
ee /boot/loader.conf 
添加if_em_load="YES" 
------------------------------------------------------ 
編譯驅(qū)動到內(nèi)核 
cd /usr/local/src/em/em-5.1.5/src 
cp if_em* /usr/src/sys/dev/em 
cp Makefile.kernel /usr/src/sys/modules/em/Makefile 
修改/usr/src/sys/conf/files.i386 文件添加以下兩行到文件 
內(nèi)
dev/em/if_em.c optional em  
dev/em/if_em_hw.c optional em  
修改你的內(nèi)核配置文件。確定有 
device em
編譯安裝內(nèi)核。。。reboot.完成
----------------------------------------------------------- 
下面說下有關(guān)網(wǎng)卡設(shè)置的參數(shù) 
ifconfig_em<interface_num>="<ifconfig_settings>" 
ifconfig em<interface_num> <IP_address> media 100baseTX mediaopt  full-duplex 
驅(qū)動所支持的模式:
autoselect - Enables auto-negotiation for speed and duplex.
   10baseT/UTP     -  Sets speed to 10 Mbps. Use the ifconfig mediaopt  
                      option to select full-duplex mode.
   100baseTX       -  Sets speed to 100 Mbps. Use the ifconfig mediaopt 
                      option to select full-duplex mode.
   1000baseTX      -  Sets speed to 1000 Mbps. In this case, the driver 
                      supports only full-duplex mode.
   1000baseSX      -  Sets speed to 1000 Mbps. In this case, the driver 
                      supports only full-duplex mode.
ifconfig em<interface_num> <hostname or IP address> mtu 9000 
route get <destination_IP_address>
[color=Red]VLANS設(shè)置[/color]建立vlan 
#ifconfig <vlan_name> create 
網(wǎng)卡的配置: 
ifconfig <vlan_name> <ip_address> netmask <subnet_mask> vlan  <vlan_id> vlandev 
<physical_interface> 
例如: 
ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan10 vlandev em0 
刪除VLAN 
#ifconfig <vlan_name> destroy
[color=Red]Polling模式:本來網(wǎng)卡工作模式:需要的時候請求中斷。但在拒絕服務(wù)攻擊情況下,包數(shù)太多,就不太
可行,polling模式就是讓cpu定期去取網(wǎng)卡內(nèi)存中的數(shù)據(jù)包。雖然平時看上去這種方法比較效率低,但在
拒絕服務(wù)攻擊情況下就比較好用。[/color] 
在內(nèi)核中確保: 
options DEVICE_POLLING 
可選: 
options HZ=1000 
polling在sysctl中參數(shù)的含義 
kern.polling.enable=1           打開polling模式 
kern.polling.burst                  每個時間片,系統(tǒng)在每個網(wǎng)卡可以抓的最多的包值,不可以改的值,根據(jù)其
他值系統(tǒng)自己算的 
kern.polling.burst_max          每次取多少內(nèi)存中的包默認(rèn)150,是 一個參數(shù),和內(nèi)核里面的HZ相乘(HZ * 
burst_max)就是每秒cpu極限可以抓的包量   默認(rèn)HZ=1000 
kern.polling.each_burst         沒搞懂用處,默認(rèn)5 好像用處不大 
kern.polling.idle_poll=1          man 中推薦打開選項 
kern.polling.reg_frac             多久檢測一次網(wǎng)卡錯誤 默認(rèn)20 
kern.polling.user_frac=10      cpu預(yù)留給userland  tasks的量 默認(rèn)50, 做防火墻推薦少留一點 
kern.polling.handlers              有多少網(wǎng)卡注冊了polling服務(wù)  不用改
注:HZ的含義以及burst_max的關(guān)系,HZ就是赫茲,時間的倒數(shù),就是多久cpu去取一次網(wǎng)卡內(nèi)存中的包 
HZ越大,CPU去取的時間間隔越短,burst_max就是每次取多少內(nèi)存中的包。 
這個參數(shù)需要自行測試,HZ越大,在大流量下用top看中斷就越多 
感覺范圍在500-2000比較合適,再大就。。。。。 
在內(nèi)核中為:options HZ=500   (我設(shè)置500,burst_max設(shè)置150,可保證我的服務(wù)器穩(wěn)定和抗攻擊能力比較好)
 
新聞熱點
疑難解答
圖片精選