之前有一個工作室的需求就是要求在一個瀏覽器窗口保持IP不變,新增一個窗口就變化IP。那就用src-address and port模式。
很多需求是為了換IP,但是並不想實現帶寬疊加的場景。
1、新建地址列表:/ip firewall address-list add add
address=192.168.120.0/24 list=LAN
2、從哪進從哪出(便於ROS對外發布服務,比如VPN等等)
add action=mark-connection chain=input comment=cnc-in connection-state=new \
in-interface=cnc-pppoe new-connection-mark=cnc-in passthrough=yes
add action=mark-routing chain=output comment=cnc-in-route connection-mark=\
cnc-in new-routing-mark=cnc-in-route passthrough=yes
add action=mark-connection chain=input comment=cnc2-in connection-state=new \
in-interface=cnc2-pppoe new-connection-mark=cnc2-in passthrough=yes
add action=mark-routing chain=output comment=cnc2-in-route connection-mark=\
cnc2-in new-routing-mark=cnc2-in-route passthrough=yes
3、mangle 標記:
/ip firewall mangle
add action=mark-connection chain=prerouting connection-mark=no-mark dst-address-type=!local new-connection-mark=C1 passthrough=yes per-connection-classifier=src-port:2/0 src-address-list=LAN
add action=mark-connection chain=prerouting connection-mark=no-mark dst-address-type=!local new-connection-mark=C2 passthrough=yes per-connection-classifier=src-port:2/1 src-address-list=LAN
add action=mark-routing chain=prerouting connection-mark=C1 new-routing-mark=R1 passthrough=yes src-address-list=LAN
add action=mark-routing chain=prerouting connection-mark=C2 new-routing-mark=R2 passthrough=yes src-address-list=LAN
4、路由策略:
/ip route
add distance=1 gateway=pppoe-out2 routing-mark=R1
add distance=1 gateway=pppoe-out3 routing-mark=R2
5、NAT 偽裝
/ip firewall nat
add action=masquerade chain=srcnat src-address-list=LAN