之前有一个工作室的需求就是要求在一个浏览器窗口保持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