歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> inter 千M網卡驅動安裝和啟用vlan.Polling抗拒絕服務

inter 千M網卡驅動安裝和啟用vlan.Polling抗拒絕服務

日期:2017/3/1 18:14:10   编辑:關於Unix

建立一個文件夾把驅動復制到裡面
#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"
------------------------------------------------------
編譯驅動到內核
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 文件添加以下兩行到文件

dev/em/if_em.c optional em
dev/em/if_em_hw.c optional em
修改你的內核配置文件。確定有
device em

編譯安裝內核。。。reboot.完成

-----------------------------------------------------------
下面說下有關網卡設置的參數
ifconfig_em<interface_num>="<ifconfig_settings>"
ifconfig em<interface_num> <IP_address> media 100baseTX mediaopt full-duplex
驅動所支持的模式:

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設置[/color]建立vlan
#ifconfig <vlan_name> create
網卡的配置:
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模式:本來網卡工作模式:需要的時候請求中斷。但在拒絕服務攻擊情況下,包數太多,就不太

可行,polling模式就是讓cpu定期去取網卡內存中的數據包。雖然平時看上去這種方法比較效率低,但在

拒絕服務攻擊情況下就比較好用。[/color]
在內核中確保:
options DEVICE_POLLING
可選:
options HZ=1000
polling在sysctl中參數的含義
kern.polling.enable=1 打開polling模式
kern.polling.burst 每個時間片,系統在每個網卡可以抓的最多的包值,不可以改的值,根據其

他值系統自己算的
kern.polling.burst_max 每次取多少內存中的包默認150,是 一個參數,和內核裡面的HZ相乘(HZ *

burst_max)就是每秒cpu極限可以抓的包量 默認HZ=1000
kern.polling.each_burst 沒搞懂用處,默認5 好像用處不大
kern.polling.idle_poll=1 man 中推薦打開選項
kern.polling.reg_frac 多久檢測一次網卡錯誤 默認20
kern.polling.user_frac=10 cpu預留給userland tasks的量 默認50, 做防火牆推薦少留一點
kern.polling.handlers 有多少網卡注冊了polling服務 不用改

注:HZ的含義以及burst_max的關系,HZ就是赫茲,時間的倒數,就是多久cpu去取一次網卡內存中的包
HZ越大,CPU去取的時間間隔越短,burst_max就是每次取多少內存中的包。
這個參數需要自行測試,HZ越大,在大流量下用top看中斷就越多
感覺范圍在500-2000比較合適,再大就。。。。。
在內核中為:options HZ=500 (我設置500,burst_max設置150,可保證我的服務器穩定和抗攻擊能力比較好)

Copyright © Linux教程網 All Rights Reserved