• 860

[研究所] MikroTik RouterOS 學習 (持續更新)

各位前輩好,小弟剛踏入RouterOS的領域,還在摸索很多東西,這兩天遇到一個問題,希望前輩能指點該如何解決問題的方向。

系統版本:RouterOS CHR 7.11.2 (stable)
路由所在位置:雙網卡主機 Windows10 VMWare
網路組建方式:中華電信小烏龜 -> 主機RJ45口A -> RouterOS -> 主機RJ45口B -> switch -> 其他聯網設備
RouterOS撥號:三個PPPoe 一個非固定制固定IP(ip.hinet.net) 兩個浮動IP(hinet.net)

目前遇到問題:於路由所在位置的主機"192.168.2.197"架設了一個遊戲(project zomboid)伺服器,想用switch後的主機"192.168.2.183"連線至該伺服器遊玩,但連線總是顯示伺服器無回應,遊戲要求端口已設NAT轉發,朋友從外網使用外網IP可以正常連線並遊玩。同時switch後還有一台Web Server,無論內外網皆可透過外網IP正常連線。

以下附上我的Filter設置和NAT設置






目前已知在"192.168.2.183"主機連線至遊戲伺服器時,在NAT會有一個input的數據,內容是"192.168.2.183" -> 遊戲伺服器外網IP,但我不知道接下來該如何處理。想請各位前輩指點路線,該往什麼方向解決或思考,感謝各位說明解惑



dufvaa1 wrote:
各位前輩好,小弟剛踏...(恕刪)




突然覺得會不會是我Loopback根本沒有做好。
又Google查了一些關鍵字,"RouterOS Game Server NAT Loopback"。
[心得]RouterOS設置Nat Loopback的注意事項
目前已經根據pctine前輩的方法2設定完成了,也特別感謝gfx前輩的額外講解,一開始還真沒有發現三種有何區別,就預設選第一種方式了。

也衍生一些問題想請教各位前輩,所以這樣等於我一開始就沒有做NAT Loopback嗎?
那為什麼同內網下的Web Server可以透過domain name訪問?
各位板上前輩大家好,最近買了一台RB450Gx4設備來學習RouterOS 7,想在家裡自建一個LAB的測試環境,計劃將使用光世代8個IP撥號上網,內網根據不同IP範圍對應到8個浮動IP出去對外網路。譬如192.168.88.100-109走第一個撥號出去,192.168.88.110-119走第二個撥號,以此類推

RB450Gx4直接接在小烏龜後面,第1個Port設定WAN利用VRRP撥號8次,第2、3個port設定成LAN,請問大概要往哪個方向去研究爬文,才能達到我想要的目的呢?
kendrv

你這個應該是要用來多播掛機用喔,可以用策略路由來做!

2023-11-03 16:04
houseplant wrote:
各位板上前輩大家好,...(恕刪)


目前7.12RC5版本有macvlan了
建議之後有升級7.12stable後用macvlan來做多個pppoe撥號
用策略路由方式來做
ROSV7的方式

table表

/routing table
add disabled=no fib name=pppoe-out2
add disabled=no fib name=pppoe-out3
add disabled=no fib name=pppoe-out4
add disabled=no fib name=pppoe-out5
add disabled=no fib name=pppoe-out6
add disabled=no fib name=pppoe-out7
add disabled=no fib name=pppoe-out8


標記

/ip firewall mangle
add action=mark-connection chain=prerouting comment=pppoe-out1 \
connection-state=new dst-address-type=local in-interface=pppoe-out1 \
new-connection-mark=pppoe1-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe1-conn \
in-interface=bridge new-routing-mark=main passthrough=no src-address=\
192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out2 \
connection-state=new dst-address-type=local in-interface=pppoe-out2 \
new-connection-mark=pppoe2-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe2-conn \
in-interface=bridge new-routing-mark=pppoe-out2 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out3 \
connection-state=new dst-address-type=local in-interface=pppoe-out3 \
new-connection-mark=pppoe3-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe3-conn \
in-interface=bridge new-routing-mark=pppoe-out3 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out4 \
connection-state=new dst-address-type=local in-interface=pppoe-out4 \
new-connection-mark=pppoe4-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe4-conn \
in-interface=bridge new-routing-mark=pppoe-out4 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out5 \
connection-state=new dst-address-type=local in-interface=pppoe-out5 \
new-connection-mark=pppoe5-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe5-conn \
in-interface=bridge new-routing-mark=pppoe-out5 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out6 \
connection-state=new dst-address-type=local in-interface=pppoe-out6 \
new-connection-mark=pppoe6-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe6-conn \
in-interface=bridge new-routing-mark=pppoe-out6 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out7 \
connection-state=new dst-address-type=local in-interface=pppoe-out7 \
new-connection-mark=pppoe3-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe7-conn \
in-interface=bridge new-routing-mark=pppoe-out7 passthrough=no \
src-address=192.168.88.0/24
add action=mark-connection chain=prerouting comment=pppoe-out8 \
connection-state=new dst-address-type=local in-interface=pppoe-out8 \
new-connection-mark=pppoe4-conn passthrough=yes src-address-type=!local
add action=mark-routing chain=prerouting connection-mark=pppoe8-conn \
in-interface=bridge new-routing-mark=pppoe-out4 passthrough=yes \
src-address=192.168.88.0/24
add action=mark-routing chain=prerouting comment="policy route" \
new-routing-mark=main passthrough=yes src-address=\
192.168.88.100-192.168.88.109
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out2 \
passthrough=yes src-address=192.168.88.110-192.168.88.119
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out3 \
passthrough=yes src-address=192.168.88.120-192.168.88.129
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out4 \
passthrough=yes src-address=192.168.88.130-192.168.88.139
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out5 \
passthrough=yes src-address=192.168.88.140-192.168.88.149
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out6 \
passthrough=yes src-address=192.168.88.150-192.168.88.159
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out7 \
passthrough=yes src-address=192.168.88.160-192.168.88.169
add action=mark-routing chain=prerouting new-routing-mark=pppoe-out8 \
passthrough=yes src-address=192.168.88.170-192.168.88.179


路由表


/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 pref-src="" routing-table=pppoe-out1 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=2 dst-address=0.0.0.0/0 gateway=pppoe-out2 pref-src="" routing-table=pppoe-out2 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=3 dst-address=0.0.0.0/0 gateway=pppoe-out3 pref-src="" routing-table=pppoe-out3 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=4 dst-address=0.0.0.0/0 gateway=pppoe-out4 pref-src="" routing-table=pppoe-out4 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=5 dst-address=0.0.0.0/0 gateway=pppoe-out5 pref-src="" routing-table=pppoe-out5 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=6 dst-address=0.0.0.0/0 gateway=pppoe-out6 pref-src="" routing-table=pppoe-out6 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=7 dst-address=0.0.0.0/0 gateway=pppoe-out7 pref-src="" routing-table=pppoe-out7 scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=8 dst-address=0.0.0.0/0 gateway=pppoe-out8 pref-src="" routing-table=pppoe-out8 scope=30 \
suppress-hw-offload=no target-scope=10
kendrv wrote:
目前7.12RC5版...(恕刪)


謝謝大神的指導幫忙,按照您的方式設定已經成功完成
驗證也成功,想請問原本內建防火牆這些設定是否可以移除
因為有看到一些Error,不知道是不是這些設定的關係




houseplant wrote:
謝謝大神的指導幫忙,...(恕刪)
您給的兩張圖,上圖firewall filter第8規則,與下圖mangle的0,1,2規則是有關聯的喔。

firewall filter第8規則是用於fasttrack,作用是nat加速,並降低cpu使用上的負載。
mikrotik路由器早期的型號要透過此規則才能跑超過300M以上,
就算是新的型號,透過fasttrack也可以讓cpu負載節省20-30%,是mikrotik極重要的功能。

而firewall mangle規則0,1,2即是fasttrack生成的,
作用是"標記fasttrack的封包略過cpu,轉交switch chip處裡"。
也就是fasttrack能節省cpu使用,靠的是switch晶片。

但注意有switch chip的路由器,肯定是官方出品的路由器。
若使用系統是採x86電腦安裝routeros系統,自然不會有觸發switch晶片的可能,
也自然不會有使用fasttrack的契機。

延續fasttrack話題,若您成功觸發fasttrack,
那您在firewall mangle下面的新增規則將會失效...
因為被fastrack標記的封包將會略過mangle策略。

所以想要使用fasttrack,又要特定電腦使用不同pppoe-out,
不能在mangle設置,得改在/routing rule設置。

不過話說回來,您已經開啟fasttrack,
在mangle指定電腦使用不同pppoe-out卻沒發生異常...
您路由器會不會是x86電腦+routeros的組合?

如果真是x86電腦+routeros的組合,
那您可以將firewall filter的fasttrack(規則8)關閉或刪除,
重開機後,mangle裡與fasttrack關聯的0,1,2規則也會跟著消失。
gfx
gfx

不是不建議開,是開了也不會有作用,因為電腦主機板不可能含mikrotik switch晶片。既然如此x86軟路由何必開fasttrack,多一個影響系統的變因。

2023-11-06 14:55
RickyHsu77

了解,但用了軟路由,不得不說X86效能真的很強,應該說CPU比ARM的效能強多了.

2023-11-07 15:03
gfx wrote:
fasttrack


感謝GFX前輩詳細的解說fasttrack的用途還有防火牆的規則,非常感謝
我是買RB450Gx4這款搭配RouterOS 7.11.2版本,接在光世代500M小烏龜後面
因為之前測試用一般無線AP刷韌體,開了多撥之後都無法跑滿500M
換了這款之後,可以順利跑滿,真的是讓人非常滿意!

也不知道為什麼開啟fasttrack搭配mangle指定電腦使用不同pppoe-out卻沒發生異常
很抱歉第一次使用RouterOS,對網路設定也不太熟悉
我把設定po出來給大家看看討論,測試真的是會對應不同的IP出去










houseplant wrote:
感謝GFX前輩詳細的...(恕刪)
原來您用的rb450gx4,
建議刪除或關閉mangle 17-24規則以正確使用fasttrack。

/routing rule先新增3個不做策略的例外狀況,
分別是作用於內網的10.0.0.0/8、172.16.0.0/12、192.168.0.0/16


接下只要這樣操做,如:192.168.88.179 => pppoe-out2

這樣新增即可。

注意如:192.168.88.10-192.168.88.129的方式是無法在/routing rule設置的,
但每個ip個別新增又太過,所以採網段分段組合方式會較佳。如:

192.168.88.10-192.168.88.129 =>
192.168.88.10/31
+ 192.168.88.12/30
+ 192.168.88.16/28
+ 192.168.88.32/27
+ 192.168.88.64/26
+ 192.168.88.128/31

192.168.88.130-192.168.88.139 =>
192.168.88.130/31
+ 192.168.88.132/30
+ 192.168.88.136/30

192.168.88.140-192.168.88.149 =>
192.168.88.140/30
+ 192.168.88.144/30
+ 192.168.88.148/31

192.168.88.150-192.168.88.159 =>
192.168.88.150/31
+ 192.168.88.152/30
+ 192.168.88.156/30

192.168.88.160-192.168.88.169 =>
192.168.88.160/29
+ 192.168.88.168/31

192.168.88.170-192.168.88.179 =>
192.168.88.170/31
+ 192.168.88.172/30
+ 192.168.88.176/30

192.168.88.180-192.168.88.189 =>
192.168.88.180/30
+ 192.168.88.184/30
+ 192.168.88.188/31

192.168.88.190-192.168.88.250 =>
192.168.88.190/31
+ 192.168.88.192/27
+ 192.168.88.224/28
+ 192.168.88.240/29
+ 192.168.88.248/31
+ 192.168.88.250/32

注意路由表的地方,您是將pppoe-out1當您的預設網路:

也就是沒規定的,自然會使用pppoe-out1網路。

如果您計畫192.168.88.10-192.168.88.129使用pppoe-out1,
您就直接省缺192.168.88.10-192.168.88.129設置吧,
再強調使用pppoe-out1真的沒必要。
若真的要指定,routing-table也應該使用代表系統的main。

然後fasttrack的規則也要改,系統給的設置並非最佳。



注意這是pppoe-out1的,您還需新增pppoe-out2 - pppoe-out7。

或者您可以改採interface-list,
將pppoe-out1 - pppoe-out7都加到共同的list,如:PPPoE
然後fasttrack規則中,將in-interface=pppoe-out1改成in-interface-list=PPPoE,
這就無需在firewall filter新增7筆雷同的fasttrack規則了。
houseplant

請教一下最後一步怎麼把全部PPPoE給綁在一起設定呢?

2023-11-07 15:20
Q:請教一下最後一步怎麼把全部PPPoE給綁在一起設定呢?

1.


2.


3.

您有7個pppoe-out,全部都需加入list=PPPoE。

完成後,interface-list=PPPoE 即代表全部7個的pppoe撥號。
gfx wrote:
Q:請教一下最後一步...(恕刪)


感謝GFX指點,全部設定上去之後,雖然可以上網
但是IP都變成是走第一條PPPoE出去
不知道是哪邊規則沒有設定到,滿奇怪的
為了開啟fasttrack功能並且把mangle改成rule,看來沒這麼簡單
還需要努力研究呢!







  • 860
內文搜尋
X
評分
評分
複製連結
請輸入您要前往的頁數(1 ~ 860)
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?