我想转发所有的TCP数据包到一个接口(一个专用的Internet连接只用于下载)和所有的UDP数据包到另一个(一个专用的互联网连接只为stream和电子游戏)。 我怎样才能做到这一点? 我的路由器是Mikrotik RB750。
如果要在两个本地连接之间拆分传入的networking通信,假设每个接口都有不同的地址,可以使用dst-nat来完成:
/ip firewall nat add in-interface=[incoming interface] action=dst-nat protocol=tcp dst-address=[TCP address] add in-interface=[incoming interface] action=dst-nat protocol=udp dst-address=[UDP address]
如果你的意思是在两个外部连接之间拆分输出stream量,并且每个连接都有不同的地址,你可以这样做:
/ip firewall nat add chain=srcnat protocol=tcp action=src-nat to-address=[TCP connection address] out-interface=[TCP interface] add chain=srcnat protocol=udp action=src-nat to-address=[UDP connection address] out-interface=[UDP interface]
你可以在/ip firewall mangle使用/ip route rule和routing-mark来强制路由path。 它和Linux下的ip rule几乎一样。
/ip route rule规则下添加规则,该/ip route rule将强制使用路由表R2或R1来select一组数据包。 这里是我的示例configuration用于路由从路由器通过一个网关的数据包,并通过另一个转发的:
[lapsio@CCR1009SWAG] > /ip firewall mangle export /ip firewall mangle add action=jump chain=prerouting jump-target=check-standard add action=accept chain=check-standard in-interface=ether1-gateway #<- all incoming packets need to use "main" table in order to "see" local links add action=accept chain=check-standard src-address-list=networkSERVICE #<-this is just example match ... #some matching criteria of packets to NOT mark here with action=accept ... add action=jump chain=check-standard jump-target=mark-standard add action=mark-routing chain=mark-standard new-routing-mark=standard passthrough=no [lapsio@CCR1009SWAG] > /ip route export /ip route add distance=1 gateway=192.168.0.6 routing-mark=standard add distance=1 gateway=192.168.10.1 /ip route rule add routing-mark=standard src-address=0.0.0.0/0 table=standard
在这里,我只使用“R2”相当于“标准” – 通过.0.6转发的数据包。 没有任何标记的数据包将通过.10.1转发。
虽然其他两个答案都是正确的,但我应该指出,这肯定不行。 游戏和stream媒体使用TCP和UDP,如果它从一个地址获得TCP数据包,从另一个地址获得UDP数据,可能无法工作。 我会build议的是确定哪些主机是游戏和stream媒体,并为每个定义单独的src-nat规则。
更好的问题是,为什么? 这个模型有什么好处?