小弟之前爬文認識了Mikrotik這個路由器,後來就決心也來玩玩RouterOS。
上週四收到了路由器,於週五弄上開始玩玩。
由於小弟使用的Seednet有一個固定IP,而我也要架設VPN(大陸使用),因此DCHP也得設好。
無奈的是~PPPoE我設好了,也確定連上線了,IP也是固定的。但是其它四個port卻沒法子上網。
怪事,怎麼會PPPoE設好,反而都沒法子上網看網頁呢?實在思不得解,只好上來求助大大了。
而小弟原先想買無線功能的路由,由於成本會高出不少,就決定原先Vigor拿來當成AP使用。
因此想要解決三大問題。
1.設好了PPPoE卻沒法子上網。
2.想要用路由器自動派IP。請求指導。(我是弄了個DCHP Server,但是仍然不能上網)
3.想要架設VPN,不知道有沒有RouterOS使用玩家,能指導一下?謝謝。
ps.小弟把路由器由4.11版升級到5.2版,基本上似乎跟4.11版沒太大的差別。多數使用Winbox。
參考 RouterOS Reference Manual, 節錄方法於 Routes, Equal Cost Multipath Routing, Policy Routing
如果需要 1:1 分配, 則在/IP Route add gateway=ISP1_GatewayIP, ISP2_GatewayIP
如果需要 1:2 分配, 則在/IP Route add gateway=ISP1_GatewayIP, ISP2_GatewayIP, ISP2_GatewayIP
就可以達到自動分配的作用, 但是針對必須要固定線路的用戶, 如P2P的用戶, 這個方法並不適用
Case 2. 不同家的ISP各一條, 但是要指定分流 (這是我主要用的方法)
首先在IP Firewall Mangle中處理好個封包的Route Marking;
1. 對Forward的用戶區分, 利用Address List將用戶分成兩個群體, 分別打上 line1, line2
/ip firewall mangle
add action=mark-routing chain=prerouting comment="Mark routing=line_1 for all LAN1 not in address_list line2" disabled=no dst-address=!192.168.0.0/16 \
in-interface=LAN1 new-routing-mark=line_1 passthrough=yes src-address-list=!line2
add action=mark-routing chain=prerouting comment="Mark routing=line_2 for all LAN1 in address_list line2" disabled=no dst-address=!192.168.0.0/16 \
in-interface=LAN1 new-routing-mark=line_2 passthrough=yes src-address-list=line2
2. 對Input/Output的管理, 確保從line1來得連線, 之後的封包也是從line1回去
add action=mark-connection chain=input comment="Mark Connection=from_line_1 for incoming connect from GWpppoe_1" connection-state=new disabled=no \
in-interface=GWpppoe_1 new-connection-mark=from_line_1 passthrough=yes
add action=mark-routing chain=output comment="packet through connection from_line_1must go back to line_1" connection-mark=from_line_1 disabled=no \
new-routing-mark=line_1 passthrough=yes
add action=mark-connection chain=input comment="Mark Connection=from_line_2 for incoming connect from GWpppoe_2" connection-state=new disabled=no \
in-interface=GWpppoe_2 new-connection-mark=from_line_2 passthrough=yes
add action=mark-routing chain=output comment="packet through connection from_line_2must go back to line_2" connection-mark=from_line_2 disabled=no \
new-routing-mark=line_2 passthrough=yes
3. 加上下面兩條用來觀察分流的結果
add action=accept chain=postrouting comment="Rouring-Mark = line_1 for report only" disabled=no routing-mark=line_1
add action=accept chain=postrouting comment="Rouring-Mark = line_2 for report only" disabled=no routing-mark=line_2
然後在IP Route 中加入相對應的Gateway指定 Route Marking即可
add check-gateway=ping comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=123.204.xxx.xxx routing-mark=line_2 scope=30 target-scope=10
add check-gateway=ping comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=114.37.xxx.xxx routing-mark=line_1 scope=30 target-scope=10
Case 3. 如果使用同一家ISP提供的兩條外線, 特徵為 2條 Gateway 的 IP 相同
請自己查電腦茶包的Blog中 http://www.minitw.com/archives/409 作者同時描述了利用nth的方式分配流出的封包的方法
分享3種Case給你, 當然還有很多方式, 玩RouterOS很有趣, 請多加油吧!