六月 24
要在RouterOS上實作QoS是不難的
實作之前首先要先知道什麼是PCQ (Per Connection Queue)
說的白話一點,PCQ就是一個最佳化後的QoS系統
如果你對PCQ的詳細技後有興趣可以到這邊觀看技術文件
強烈建議一定要去看一下PCQ的技術文件,裡面有很多很好的觀念
如果要實作PCQ可以參考這篇文章PCQ Examples
如果你有在RouterOS上啟用Web-Proxy,而且要使用PCQ的話請參考
Queue with Masquerading and Internal Web-Proxy
0
PCQ除了可以實作一般的限流外,也可以配合Burst這個參數來讓網頁開啟更順暢
怎麼說呢?我舉個例子:
假設我們想讓使用者下載檔案時速度限制在10KB/s,但是如果連開網頁也限制在10KB/s,豈不是等到瘋掉。
這時候Burst這個參數就派上用場了。我們知道一般網頁的檔案都很小,下載不需要花費很多時間。而一般的檔案都很大,下載需要花很多時間。
這時候我們是不是可以多一個功能,在一開始的時候速度限制在50KB,
但是如果這個連線一直持續下載超過5MB時,就開始限速10KB/s,該怎麼做呢?就是用前面所說的Burst參數
在RouterOS中Winbox的介面如下

其中Queue Type 的設定如下圖示所
如果你需要更詳細的PCQ參數設定,可以參考這份文件 MikroTik RouterOS Workshop QoS Best Practice

0
這邊補充說明一下~~RouterOS裡 1M bits/s = 1,000,000 bits/s = 125,000 Bytes/s = 122KB/s
Max Limit :常態時的速度限制
Burst Limit:瞬時的最高速度限制
Burst Threshold:平均流量(需與Burst Time搭配使用)到達多少時開始停止使用Burst Limit
以上面這張圖片的設定檔來做說明的話
****************************************************************
一開始流量可以衝到4M bits/s
但是如果流量維持在 1Mbits/s 以上,而且在5秒內下載量達到 610KB (1M bits/s * 5)時
就停止使用Burst Limit而開始啟用Max Limit,此後速度會一直限速在2M bits/s
****************************************************************
以圖片來說明的話,流量會像下面的圖一樣
綠色的線就是使用者可以感受到的網路速度

六月 22
今天在試PsTools中的psexec時,怎麼試就是會出現下面這串文字
Error establishing communication with PsExec service on XXXXX:
所有的管道例項都在使用中。
翻成英文的錯誤訊息就是
Error establishing communication with PsExec service on XXXXX:
All pipe instances are busy.
上網問了一下 google 找到這篇
PSexec error - All pipe instances are busy
結果兇手就是 NOD32。把即時掃瞄關掉就正常了
六月 03
首先先說明一下實做的環境,如下圖

要在 RouterOS 中實現多條 ADSL 負載平衡與自動備援並不困難
但是主要的問題會是 ADSL 的 閘道(Gateway),都是同一個位置(假設是同一家ISP)
要解決這個問題必需使用 Mangle 裡的標記(mark) 且配合 nth,請看以下範例
使用 Mangle 裡的標記(mark) 且配合 nth 可以解決ADSL 負載平衡的問題。
而自動備援的問題,則是在 NAT 裡加入一行不指定條件的 masquerade 即可(需放置於正常有指定條件masquerade的後面)
設定檔的使用方式很簡單,先在 Winbox 的左邊點選 New Terminal
然後把下面的設定檔貼上就可以了
#以下設定檔在 RouterOS 3.20 下測試通過
/interface pppoe-client
add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\
"" dial-on-demand=no disabled=no interface=掛載ADSL-1的網卡 max-mru=1480 max-mtu=1480 \
mrru=disabled name=ADSL-1 password=ADSL-1密碼 profile=default service-name="" \
use-peer-dns=yes user=ADSL-1帳號
add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\
"" dial-on-demand=no disabled=no interface=掛載ADSL-2的網卡 max-mru=1480 max-mtu=1480 \
mrru=disabled name=ADSL-2 password=ADSL-2密碼 profile=default service-name="" \
use-peer-dns=yes user=ADSL-2帳號
/ip firewall mangle
#讓外部可以連通本機多條 ADSL
add action=mark-connection chain=input comment=\
"\C5\FD\A5~\B3\A1\A5i\A5H\B3s\B3q\A5\BB\BE\F7\A6h\B1\F8 ADSL" disabled=no \
in-interface=ADSL-1 new-connection-mark=from_adsl_1 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=from_adsl_1 \
disabled=no new-routing-mark=to_adsl_1 passthrough=yes
add action=mark-connection chain=input comment="" disabled=no in-interface=\
ADSL-2 new-connection-mark=from_adsl_2 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=from_adsl_2 \
disabled=no new-routing-mark=to_adsl_2 passthrough=yes
#內部網路負載平衡
add action=mark-connection chain=prerouting comment=\
"\A4\BA\B3\A1\BA\F4\B8\F4\ADt\B8\FC\A5\AD\BF\C5" connection-state=new \
disabled=no in-interface=請改成你的內部網卡 new-connection-mark=nth_1 nth=2,1 \
passthrough=yes
add action=mark-routing chain=prerouting comment="" connection-mark=nth_1 \
disabled=no in-interface=請改成你的內部網卡 new-routing-mark=to_adsl_1 passthrough=no
add action=mark-connection chain=prerouting comment="" connection-state=new \
disabled=no in-interface=請改成你的內部網卡 new-connection-mark=nth_2 passthrough=yes
add action=mark-routing chain=prerouting comment="" connection-mark=nth_2 \
disabled=no in-interface=請改成你的內部網卡 new-routing-mark=to_adsl_2 passthrough=no
/ip firewall nat
#線路正常時,依負載平衡走不一樣的 ADSL 線路出去
add action=masquerade chain=srcnat comment="\BDu\B8\F4\A5\BF\B1`\AE\C9\A1A\A8\
\CC\ADt\B8\FC\A5\AD\BF\C5\A8\AB\A4\A3\A4@\BC\CB\AA\BA ADSL \BDu\B8\F4\A5X\
\A5h" disabled=no out-interface=ADSL-1 routing-mark=to_adsl_1
add action=masquerade chain=srcnat comment="" disabled=no out-interface=\
ADSL-2 routing-mark=to_adsl_2
#ADSL 斷線自動備援
add action=masquerade chain=srcnat comment=\
"ADSL \C2_\BDu\A6\DB\B0\CA\B3\C6\B4\A9" disabled=no
/ip route
#設定 ADSL 路由
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=ADSL-1 \
routing-mark=to_adsl_1
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=ADSL-2 \
routing-mark=to_adsl_2
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
ADSL-1,ADSL-2
/ip route print
六月 02
如果你在 MYSQL 強制設定
default-character-set = utf8
default-collation = utf8_general_ci
OSCommeric 還是不吃你這一套,存進去的資料仍然不會是UTF8

首先請先用 OSCommeric 備份你的資料庫,備份完後請先用文字檔確認內容沒有亂碼。(很重要,後面會用到)
接下來在下面2個檔案中修改程式
osc/includes/application_top.php
osc/admin/includes/application_top.php
找到
tep_db_connect() or die('Unable to connect to database server!');
修改成下面這個樣子(2個檔案都要修改)
tep_db_connect() or die('Unable to connect to database server!');
if (substr(mysql_get_server_info(), 0, 3) >= '4.1') {
tep_db_query("SET NAMES 'UTF8'");
}
改完後你會發現原來正常顯示的資料都變成亂碼,不用緊張
這時候再把我們之前備份的資料庫再還原回去(再次提醒還原前一定要確認備份的檔案內容是正常的,沒有亂碼的)
還原完成後,資料庫與網頁的顯示就都正常了。