之前免費的防火牆路由器架好後,雖然都是brazilfw,但一直沒有機會實測看看NAT效能。因為單位內部走的仍舊是虛擬ip。
今天,也蠻無聊的,不如就才測看看之前用就電腦架的brazilfw的nat效能如何。
這台目前的配備:
Linux 核心版本
2.4.36.2
機器
Intel(R) Celeron(R) CPU 2.20GHz
2192.961
RAM 1GB
硬碟: 80G
一般跑nat的效能,影響由大而小是:
CPU > 記憶體 > OS > 網路卡
當封包進入設備時,會由處理器根據 封包表頭 提供資訊決定流向, 當然開啟越多的功能(防毒,防火牆規則等),就會消耗更多處理器資源。
另外,在pfSense 網站上也有提到,針對相關需求的路由器設備要求項目如下:
- Throughput required
- Features that
will be used
也就是看個人的流量決定以及打開的功能來決定我們需要什麼等級的主機。
以下是對於處理器的要求:
10-20
Mbps - No less than 266 MHz CPU
21-50 Mbps - No less than 500 MHz
CPU
51-200 Mbps - No less than 1.0 GHz CPU
201-500 Mbps - server
class hardware with PCI-X or PCI-e network adapters, or newer desktop
hardware with PCI-e network adapters. No less than 2.0 GHz CPU.
501+
Mbps - server class hardware with PCI-X or PCI-e network adapters. No
less than 3.0 GHz CPU.
看來一般就款主機理論上應該可以勝任。
底下這張圖示我在測試nat流量時cpu的負載(原本 0.1),測量時跑到0.86,理論上應該還好(而且現在也很多CLIENT在線上)
VPN 應該是最吃效能的,這各部分我今天沒有測,但是可以看看以下的說明:
VPN -
Heavy use of any of the VPN services included in pfSense will increase
CPU requirements. Encrypting and decrypting traffic is CPU intensive.
The number of connections is much less of a concern than the throughput
required. A 266 MHz CPU will max out at around 4 Mbps of IPsec
throughput, a 500 MHz CPU can push 10-15 Mbps of IPsec, and relatively
new server hardware (Xeon 800 FSB and newer) deployments are pushing
over 100 Mbps with plenty of capacity to spare. Supported encryption
cards, such as several from Hifn, are capable of significantly reducing
CPU requirements.
Captive portal 一般用來web認證使用者上網行為,這個當然也是吃cpu。
Captive portal - While the
primary concern is typically throughput, environments with hundreds of
simultaneous captive portal users (of which there are many) will require
slightly more CPU power than recommended above.
一般網管會強調到的 Session數量,就是底下所講的,被記憶體所影響。
一般一個 State table entries 會使用掉 1Kb的記憶體 -----------這個怎麼計算,得去查察TCP/IP才行。
但我們可以粗估計算,
1MB 可以給予 1000個 Session 數量
100MB 應該可以給予 100,000 個 Session 數量。所以想要加大Session就是要靠記憶體。
Large
state tables - State table entries require about 1 KB of RAM
each. The default state table, when full at 10,000 entries, takes up a
little less than 10 MB RAM. For large environments requiring state
tables with hundreds of thousands of connections, ensure adequate RAM is
available.
順便複習我上次的指令:
sed -n 's%.* src=\(192.168.[0-99.]*\).*%\1%p' /proc/net/ip_conntrack | sort | uniq -c
把區網內目前使用 State table entries的電腦分別列出,目前單位用不到 1000條。
======================================================
現在才開始要來介紹 iperf 這個軟體:
一般linux 主機上都有,所以我拿我們單位的主機來當測試server (防火牆外)
在主機上輸入 指令 iperf -s

測試客端機其實也不難,因為我用WINOWS 測試 ,所以先到這邊下載:
https://publishing.ucf.edu/sites/itr/cst/Pages/IPerf.aspx
然後利用dos 模式,打上下列指令:
iperf.exe -c 163.22.xxx.xxx -w 128k -t 120 -i 10 中間的ip就是主機的ip( 兩台中間經過要測的防火牆主機)

真的很慘,怎麼會只有 12 Mbits 左右咧,這個開始讓我感興趣了,等暑假來了,我再來測看看吧。
為什麼今天突然想要測 nat效能呢?
請看看底下兩張圖:
一、經過nat 主機後的下載速度: (大約在 2Mb/s 左右)
二、未經過nat 主機的 下載速度: 大約 10Mb/s 左右
不過還是先說好,這個是不負責測試,因為nat主機當然還開了其他許多功能,速度會下降是理所當然的,所以等有空時,一定要想辦法把主機效能操出來。