外观
ROS配置
约 947 字大约 3 分钟
10.0.0.2是smbox的ip
如果配置了ipv6,在ipv6 -> ND -> bridge 取消勾选:Advertise DNS
配置思路:两步缺一不可
SMbox 的分流需要 DNS 和 路由 两步配合才能生效:
- 第一步 DNS 分流:把需要代理的域名解析成 FakeIP(
198.18.0.0/15段)。 - 第二步 路由分流:把 FakeIP 网段、以及 Telegram 等纯 IP 连接的流量引导到 SMbox。
DNS 只决定「哪些域名被解析成 FakeIP」,真正把流量送进 SMbox 靠的是路由规则。只配 DNS 不配路由,设备能解析出 FakeIP 却无法上网。 下面第一步的两种 DNS 模式只是二选一,但第二步路由分流无论选哪种 DNS 都必须配置。
第一步:DNS 分流(两种模式二选一)
下面两种模式效果一致,根据自己情况二选一即可,点击下方标签切换查看。
方式一(推荐):LAN DHCP 下发 SMBOX 的 IP
LAN DHCP 下发 SMbox 的 IP 作为 DNS,所有设备的 DNS 请求直接交给 SmboxDNS,再由 SMbox 内部的「DNS 分流模式 + 例外设备」控制哪些设备走代理。

方式二:ROS DNAT 劫持分流
配置LAN口的DHCP将DNS改为Routeros的IP,配置方法参考上图。再用 DNAT 把需要代理设备的 53 端口流量劫持到 SMbox。
任何时候不要把Smbox的IP加入到proxy_device中,否则会引起环回导致崩溃。
设置代理的设备,下方2选一:
(推荐)点击 ip -> dhcp server -> lease 找到需要代理的设备,选中,点击make static,然后双击编辑,address list那里填上proxy_device即可
例如本地ip为10.0.0.20,添加到address-list中,千万不要把SMbox的ip加入到proxy_device中,否则会环回
/ip firewall address-list
add address=10.0.0.20 list=proxy_device配置 DNS 劫持:
/ip/firewall/nat/add chain=dstnat action=dst-nat dst-address=10.0.0.1 protocol=udp dst-port=53 src-address-list=proxy_device to-addresses=10.0.0.2 to-ports=53 comment=proxy_dnsnat
/ip/firewall/nat/add chain=dstnat action=dst-nat dst-address=10.0.0.1 protocol=tcp dst-port=53 src-address-list=proxy_device to-addresses=10.0.0.2 to-ports=53 comment=proxy_dnsnat第二步:路由分流(必做)
无论上一步选哪种 DNS,这一步都必须配置
DNS 只把域名解析成了 FakeIP,把 FakeIP 网段和纯 IP 连接(如 Telegram)的流量真正送到 SMbox,靠的是下面的路由分流规则。漏掉这一步会导致设备能解析出 FakeIP 却无法访问。
将需要代理的目标ip,添加到address-list中,这些是fakeip的网段和tg的ip,因为TG是纯IP连接的。别的软件可能也有纯IP连接的,根据自己需要添加。
/ip firewall address-list
add address=91.108.56.0/22 list=proxy_cidr
add address=91.108.4.0/22 list=proxy_cidr
add address=91.108.8.0/22 list=proxy_cidr
add address=91.108.16.0/22 list=proxy_cidr
add address=91.108.12.0/22 list=proxy_cidr
add address=149.154.160.0/20 list=proxy_cidr
add address=91.105.192.0/23 list=proxy_cidr
add address=91.108.20.0/22 list=proxy_cidr
add address=185.76.151.0/24 list=proxy_cidr
add address=198.18.0.0/15 list=proxy_cidr下方10.0.0.2要改为你自己smbox的ip 10.0.0.1改为自己路由器的ip 10.0.0.0/24改为你自己的网段
/routing/table/add name=proxy fib
/ip/route/add gateway=10.0.0.2 routing-table=proxy comment=proxy_route
/ip/firewall/mangle/add chain=prerouting dst-address-list=proxy_cidr action=mark-routing new-routing-mark=proxy passthrough=yes/ip/firewall/nat/add chain=srcnat action=masquerade src-address=10.0.0.0/24 dst-address=10.0.0.2如果你配置了防火墙,需要添加accept规则
/ip/firewall/filter/add chain=forward dst-address-list=proxy_cidr action=accept place-before=1
/ip/firewall/filter/add chain=forward src-address-list=proxy_cidr action=accept place-before=1ros 配置双smbox高可用(可选)
主smbox:10.0.0.2 次smbox:10.0.0.12 下方主次ip要改为你自己的! 简而言之就是,监听主smbox的8888端口,如果在运行就切换到主smbox,不在运行就切换到次的smbox。 打开tools -> netwatch 
点击Up填入以下脚本
/ip/route/set [/ip/route/find comment="proxy_route"] gateway=10.0.0.2
/ip/firewall/nat/set [/ip/firewall/nat/find comment="proxy_dnsnat"] to-addresses=10.0.0.2Down填入以下脚本
/ip/route/set [/ip/route/find comment="proxy_route"] gateway=10.0.0.12
/ip/firewall/nat/set [/ip/firewall/nat/find comment="proxy_dnsnat"] to-addresses=10.0.0.12