找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888广告投放联系QQ68610888
广告投放联系QQ68610888广告投放联系QQ68610888
查看: 420|回复: 3

ai写个routeros的完整脚本,求指点。求完善

[复制链接]
发表于 2026-5-24 00:29 | 显示全部楼层 |阅读模式
安装x86的ros。接入三个网卡,网卡1管理,网卡2作为lan并dhcp。网卡3复制vlan多拨。

脚本开启nat1+upnp。并且针对ipv4和ipv6做好路由。v4进行负债均衡。v6全体下发公网ip。并且都是打了特征避免流量迷路,同时进行了负载均衡设置。全适应。
一号口为5网段,2号口为13网段,保障1号口与二号口之间内网设备可以畅通链接。(脚本全部运行后由winbo人工选择要拨号开启的线路)
并且设置了应对突然断线,重拨等应对。设置了dhcp。同时满足静态ip的访问等。具体脚本如下,但是实际使用发现存在分配dhcp为何无法上网?或者dhcp失败,或者其他情况。

请ros大神以及ai玩家完善并修复该脚本,这样大家都可以用上方便的ros。
也增加了容器面板的配合监控。
主要是想多拨来给pcdn设备使用。大家应该也有这个需求,ros性能比较好。

我实在用ai搞了好久,几个ai互相改,只能搞成这样了,几个版本,我就给一个最后的吧,大家再次基础上操作。也欢迎解答疑问。

==============================================

# =====================================================================
# 模块一:MikroDash 看板专属只读 API 账户激活
# =====================================================================
/user remove [find name="mikrodash_user"]
/user group remove [find name="mikrodash_group"]
/user group add name=mikrodash_group policy=read,api
/user add name="mikrodash_user" group=mikrodash_group password="dash_admin_888" comment="MikroDash Monitor Account"
/ip service set api disabled=no port=8728
:put "=== ✅ 模块一:API 只读账户覆盖刷新成功 ==="

/delay 1s
# =====================================================================
# 模块二:ROS v7 专属内核策略路由表(FIB)注册
# =====================================================================
/routing table remove [find name~"to_"]
/routing table add name=to_129-1 fib
/routing table add name=to_129-2 fib
/routing table add name=to_129-3 fib
/routing table add name=to_59-1 fib
/routing table add name=to_59-2 fib
/routing table add name=to_59-3 fib
/routing table add name=to_40-1 fib
/routing table add name=to_40-2 fib
/routing table add name=to_40-3 fib
:put "=== ✅ 模块二:v7 核心路由表规则覆盖完毕 ==="

/delay 1s
# =====================================================================
# 🧱 模块三:物理 3 号网口 VLAN 铺设与 PPPoE 静默创建
# =====================================================================
/interface pppoe-client remove [find name~"pppoe-129"]
/interface pppoe-client remove [find name~"pppoe-59"]
/interface pppoe-client remove [find name~"pppoe-40"]
/interface macvlan remove [find name~"vif-129-"]
/interface macvlan remove [find name~"vif-59-"]
/interface macvlan remove [find name~"vif-40-"]
/interface vlan remove [find name="vif-129"]
/interface vlan remove [find name="vif-59"]
/interface vlan remove [find name="vif-40"]

/interface vlan add interface=ether3 name="vif-129" vlan-id=129
/interface vlan add interface=ether3 name="vif-59" vlan-id=59
/interface vlan add interface=ether3 name="vif-40" vlan-id=40

# 129 号段 Macvlan 与 PPPoE 矩阵
/interface macvlan add name="vif-129-1" interface="vif-129" mac-address="00:00:00:00:00:A1"
/interface macvlan add name="vif-129-2" interface="vif-129" mac-address="00:00:00:00:00:A2"
/interface macvlan add name="vif-129-3" interface="vif-129" mac-address="00:00:00:00:00:A3"
/interface pppoe-client add name="pppoe-129-1" interface="vif-129-1" user="XXXX" password="XXXX"disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-129-2" interface="vif-129-2" user= "XXXX"password="XXXX" disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-129-3" interface="vif-129-3" user="XXXX" password="XXXX"disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492

# 59 号段 Macvlan 与 PPPoE 矩阵
/interface macvlan add name="vif-59-1" interface="vif-59" mac-address="00:00:00:00:00:A4"
/interface macvlan add name="vif-59-2" interface="vif-59" mac-address="00:00:00:00:00:A5"
/interface macvlan add name="vif-59-3" interface="vif-59" mac-address="00:00:00:00:00:A6"
/interface pppoe-client add name="pppoe-59-1" interface="vif-59-1" user="XXXX" password="XXXX" disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-59-2" interface="vif-59-2" user="XXXX" password="XXXX" disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-59-3" interface="vif-59-3" user="XXXX" password="XXXX" disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492

# 40 号段 Macvlan 与 PPPoE 矩阵
/interface macvlan add name="vif-40-1" interface="vif-40" mac-address="00:00:00:00:00:A7"
/interface macvlan add name="vif-40-2" interface="vif-40" mac-address="00:00:00:00:00:A8"
/interface macvlan add name="vif-40-3" interface="vif-40" mac-address="00:00:00:00:00:A9"
/interface pppoe-client add name="pppoe-40-1" interface="vif-40-1" user=user="XXXX" password="XXXX"disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-40-2" interface="vif-40-2" user=user="XXXX" password="XXXX"disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
/interface pppoe-client add name="pppoe-40-3" interface="vif-40-3" user=user="XXXX" password="XXXX"disabled=yes add-default-route=no use-peer-dns=no max-mru=1492 max-mtu=1492
:put "=== ✅ 模块三:9线 PPPoE 矩阵静默创建完毕 ==="

/delay 1s
# =====================================================================
# 模块四:全局直通白名单、NAT1 榨汁与内核防火墙优化
# =====================================================================
/ip firewall nat remove [find comment~"NAT1_"]
/ip firewall nat remove [find comment~"Default_Masq_"]
/ip firewall raw remove [find comment="DNS_Exemption"]
/ip firewall filter remove [find comment="Drop_Invalid_Packets_Directly"]
/ip firewall mangle remove [find comment="LAN_All_Internal_Bypass"]
/ip firewall address-list remove [find list=LAN_Private_Subnets]
/ipv6 firewall raw remove [find comment="Allow_DHCPv6_Client"]

/ip firewall address-list add list=LAN_Private_Subnets address=10.0.0.0/8
/ip firewall address-list add list=LAN_Private_Subnets address=172.16.0.0/12
/ip firewall address-list add list=LAN_Private_Subnets address=192.168.0.0/16

# 为保障 PCC 负载均衡生效,必须完全禁用系统默认的 FastTrack,否则并发大包会逃逸路由表规则
/ip firewall filter set [find action="fasttrack-connection"] disabled=yes

# LAN 至 LAN (含返回流量) 绕过 PCC,节省 CPU
/ip firewall mangle add chain=prerouting dst-address-list=LAN_Private_Subnets action=accept comment="LAN_All_Internal_Bypass" place-before=0

/ip firewall raw add chain=prerouting protocol=udp dst-port=53 action=accept comment="DNS_Exemption"
/ip firewall filter add chain=input connection-state=invalid action=drop comment="Drop_Invalid_Packets_Directly"
/ip firewall filter add chain=forward connection-state=invalid action=drop comment="Drop_Invalid_Packets_Directly"
/ipv6 firewall raw add chain=prerouting protocol=udp dst-port=546 action=accept comment="Allow_DHCPv6_Client"

# 1. NAT1 榨汁规则 (仅对 UDP 实施 Full-Cone 行为,按最高优先级写入)
/ip firewall nat add chain=srcnat out-interface="pppoe-129-1" action=endpoint-independent-nat protocol=udp comment="NAT1_129-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-129-2" action=endpoint-independent-nat protocol=udp comment="NAT1_129-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-129-3" action=endpoint-independent-nat protocol=udp comment="NAT1_129-3"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-1" action=endpoint-independent-nat protocol=udp comment="NAT1_59-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-2" action=endpoint-independent-nat protocol=udp comment="NAT1_59-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-3" action=endpoint-independent-nat protocol=udp comment="NAT1_59-3"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-1" action=endpoint-independent-nat protocol=udp comment="NAT1_40-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-2" action=endpoint-independent-nat protocol=udp comment="NAT1_40-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-3" action=endpoint-independent-nat protocol=udp comment="NAT1_40-3"

# 2. 通用伪装规则 (兜底 TCP/ICMP 控制流)
/ip firewall nat add chain=srcnat out-interface="pppoe-129-1" action=masquerade comment="Default_Masq_129-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-129-2" action=masquerade comment="Default_Masq_129-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-129-3" action=masquerade comment="Default_Masq_129-3"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-1" action=masquerade comment="Default_Masq_59-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-2" action=masquerade comment="Default_Masq_59-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-59-3" action=masquerade comment="Default_Masq_59-3"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-1" action=masquerade comment="Default_Masq_40-1"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-2" action=masquerade comment="Default_Masq_40-2"
/ip firewall nat add chain=srcnat out-interface="pppoe-40-3" action=masquerade comment="Default_Masq_40-3"

:put "=== ✅ 模块四:NAT1 穿透引擎与多链路安全闭环部署完毕 ==="

/delay 1s
# =====================================================================
# 模块五:物理断线流量黑洞规则
# =====================================================================
/ip route remove [find comment~"Gate_"]
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_129-1 distance=250 comment="Gate_129-1"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_129-2 distance=250 comment="Gate_129-2"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_129-3 distance=250 comment="Gate_129-3"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_59-1 distance=250 comment="Gate_59-1"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_59-2 distance=250 comment="Gate_59-2"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_59-3 distance=250 comment="Gate_59-3"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_40-1 distance=250 comment="Gate_40-1"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_40-2 distance=250 comment="Gate_40-2"
/ip route add dst-address=0.0.0.0/0 type=blackhole routing-table=to_40-3 distance=250 comment="Gate_40-3"
:put "=== ✅ 模块五:物理掉线防串线黑洞部署完毕 ==="

/delay 1s
# =====================================================================
# 模块六:9路动态 IPv6 索要与 ether2 自动广播下发
# =====================================================================
/ppp profile set [find name="default"] use-ipv6=yes
/ipv6 dhcp-client remove [find comment~"v6_dhcp_"]
/ipv6 address remove [find comment~"v6_lan_"]
{
  :local lines {"pppoe-129-1";"pppoe-129-2";"pppoe-129-3";"pppoe-59-1";"pppoe-59-2";"pppoe-59-3";"pppoe-40-1";"pppoe-40-2";"pppoe-40-3"}
  :foreach ln in=$lines do={
    :local pName ("pool_" . $ln)
    :local cmtDhcp ("v6_dhcp_" . $ln)
    :local cmtLan ("v6_lan_" . $ln)
    :if ($ln = "pppoe-129-1") do={
      /ipv6 dhcp-client add interface=$ln request=prefix pool-name=$pName pool-prefix-length=64 add-default-route=yes use-peer-dns=no disabled=no comment=$cmtDhcp
    } else={
      /ipv6 dhcp-client add interface=$ln request=prefix pool-name=$pName pool-prefix-length=64 add-default-route=no use-peer-dns=no disabled=no comment=$cmtDhcp
    }
    # 强制标记为 /64 掩码,确保 SLAAC 标准广播给内网下级设备
    /ipv6 address add interface=ether2 address=::1/64 from-pool=$pName advertise=yes comment=$cmtLan
  }
}
/ipv6 settings set forward=yes accept-router-advertisements=yes
/ipv6 nd set [find default=yes] interface=ether2 advertise-dns=yes advertise-mac-address=yes managed-address-configuration=no other-configuration=no disabled=no
:put "=== ✅ 模块六:IPv6 多前缀并发下发部署成功 ==="

/delay 1s
# =====================================================================
# 模块七:自动化调度大脑(Adaptive_Engine 容错无死角终极重构版)
# =====================================================================
/system script remove [find name="Adaptive_Engine"]
/system scheduler remove [find name="Run_Adaptive_Engine"]
/ip firewall mangle remove [find comment~"MikroDash_PCC_"]
/ip route remove [find comment~"Dyn_"]

/system script add name="Adaptive_Engine" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source='
:local lanIf "ether2"
:local prefixList {"pppoe-129-1";"pppoe-129-2";"pppoe-129-3";"pppoe-59-1";"pppoe-59-2";"pppoe-59-3";"pppoe-40-1";"pppoe-40-2";"pppoe-40-3"}

# 使用字符串拼接以规避 [:toarray ""] 产生空值索引的致命 Bug
:local activeStr ""
:foreach line in=$prefixList do={
    :local iface [/interface find name=$line]
    :if ([:len $iface] > 0) do={
        :if ([/interface get $iface running] = true) do={
            :if ([:len $activeStr] > 0) do={
                :set activeStr ($activeStr . "," . $line)
            } else={
                :set activeStr $line
            }
        }
    }
}

:local activeLines [:toarray $activeStr]
:local activeCount [:len $activeLines]
:if ([:len $activeStr] = 0) do={ :set activeCount 0 }

:global lastActiveLinesSignature
:local currentSignature ($activeCount . "-" . [:tostr $activeLines])

:if ($lastActiveLinesSignature != $currentSignature) do={
    /ip firewall mangle remove [find comment~"MikroDash_PCC_"]
    /ip route remove [find comment~"Dyn_"]
   
    :if ($activeCount > 0) do={
        :local masterGate ($activeLines->0)
        /ip route add dst-address=0.0.0.0/0 gateway=$masterGate distance=1 comment="Dyn_Main_Stable_Gate"
        
        :for i from=1 to=$activeCount do={
            :local line ($activeLines->($i-1))
            /ip firewall mangle add chain=input in-interface=$line action=mark-connection new-connection-mark=("conn_" . $line) passthrough=yes comment=("MikroDash_PCC_In_" . $line)
            /ip firewall mangle add chain=prerouting in-interface=$line action=mark-connection new-connection-mark=("conn_" . $line) passthrough=yes comment=("MikroDash_PCC_In_" . $line)
        }
        
        :for i from=1 to=$activeCount do={
            :local line ($activeLines->($i-1))
            /ip firewall mangle add chain=prerouting in-interface=$lanIf dst-address-type=!local connection-state=new dst-address-list=!LAN_Private_Subnets action=mark-connection new-connection-mark=("conn_" . $line) passthrough=yes per-connection-classifier=("both-addresses-and-ports:" . $activeCount . "/" . ($i-1)) comment=("MikroDash_PCC_Core_" . $line)
        }
        
        :for i from=1 to=$activeCount do={
            :local line ($activeLines->($i-1))
            :local table ("to_" . [:pick $line 6 [:len $line]])
            /ip firewall mangle add chain=prerouting src-address-list=LAN_Private_Subnets connection-mark=("conn_" . $line) action=mark-routing new-routing-mark=$table passthrough=no comment=("MikroDash_PCC_Out_" . $line)
            /ip firewall mangle add chain=output connection-mark=("conn_" . $line) action=mark-routing new-routing-mark=$table passthrough=no comment=("MikroDash_PCC_Out_" . $line)
            /ip route add dst-address=0.0.0.0/0 gateway=$line routing-table=$table distance=1 comment=("Dyn_Gate_" . $line)
        }
    }
    :set lastActiveLinesSignature $currentSignature
    :log warning ("Adaptive_Engine: 动态多线路由已刷新,当前在线线路数: " . $activeCount)
}'

/system scheduler add name="Run_Adaptive_Engine" interval=15s start-time=startup on-event="Adaptive_Engine"
:put "=== ✅ 模块七:动态调度大脑静默注册就绪(等待后续拨号上线触发) ==="

只谈技术、莫论政事!(点击见详情) | 互相尊重、友善交流、切勿过度反应、玻璃心。胡乱输入灌水等操作将会被封禁ID。
发表于 2026-5-24 06:43 | 显示全部楼层
你这个脚本的核心思路其实已经非常接近“可用级生产方案”了:

* VLAN 多拨
* macvlan 批量 PPPoE
* PCC 负载均衡
* NAT1 / Full Cone
* IPv6 Prefix 下发
* 动态故障切换
* 黑洞防串线
* DHCP
* 内网互通
* MikroDash 监控

这些方向都没问题。

但你现在遇到的:

* DHCP 拿到 IP 但无法上网
* DHCP 偶尔失败
* 某些设备能 ping 路由但不能出网
* IPv6 有地址但不能访问公网
* 某些线路断线后流量迷路
* 某些设备随机掉线

本质原因不是单一问题。

而是:

你现在的脚本已经进入“ROS v7 多路策略路由复杂体系”,里面有几个非常典型的坑。

我仔细看了你整个脚本后,发现有 11 个关键问题。

下面我按“致命级 → 严重级 → 优化级”给你拆。

---

# 一、最致命的问题(DHCP 正常但不能上网)

这是你现在最大的问题。

核心 bug:

```routeros
/ip firewall mangle add chain=prerouting \
src-address-list=LAN_Private_Subnets \
connection-mark=("conn_" . $line) \
action=mark-routing
```

这里完全错了。

因为:

```routeros
src-address-list=LAN_Private_Subnets
```

匹配的是:

10.x
172.x
192.168.x

但:

你的 LAN 客户端根本没有被加入 address-list。

你只是创建了:

```routeros
/ip firewall address-list add list=LAN_Private_Subnets address=192.168.0.0/16
```

这只是“目标网段匹配”。

不是动态客户端列表。

结果:

PCC 标记后的连接,
后续 routing-mark 根本没被正确命中。

于是:

* DHCP 正常
* DNS 正常
* 但路由没进策略表
* 流量掉回 main
* main 没默认路由
* 最终无法上网

这就是你最主要的问题。

---

# 正确做法

这里应该改成:

```routeros
in-interface=$lanIf
```

而不是:

```routeros
src-address-list=LAN_Private_Subnets
```

正确逻辑:

```routeros
/ip firewall mangle add chain=prerouting \
in-interface=$lanIf \
connection-mark=("conn_" . $line) \
action=mark-routing \
new-routing-mark=$table
```

这是第一大修复。

也是 DHCP 后不能上网的核心原因。

---

# 二、PCC 与 FastTrack 冲突虽然处理了,但还不完整

你虽然:

```routeros
/ip firewall filter set [find action="fasttrack-connection"] disabled=yes
```

但问题是:

有些 ROS 默认配置里:

FastTrack 不止一个。

有:

```routeros
fasttrack-connection hw-offload=yes
```

你这个 find 未必全命中。

建议:

彻底删除:

```routeros
/ip firewall filter remove [find action=fasttrack-connection]
```

否则:

部分连接绕过 mangle。

PCC 会随机失效。

---

# 三、你的 IPv6 下发方式存在重大逻辑问题

你现在:

9 条 PPPoE
9 个 PD Prefix

全部:

```routeros
/ipv6 address add interface=ether2 from-pool=$pName advertise=yes
```

这是错的。

原因:

一个 LAN 口同时广播多个 /64 Prefix。

很多设备:

* 安卓
* Windows
* iOS

会随机选源地址。

然后:

出口线路与源 IPv6 不匹配。

ISP 做 strict anti-spoof 时:

直接丢包。

于是:

你看到:

* IPv6 有公网地址
* 但部分网站打不开
* 或随机断流

这就是经典:

IPv6 流量迷路。

---

# 正确方案

不要:

多个 PD 全部广播到同一个 LAN。

应该:

## 方案1(推荐)

只广播一个 IPv6 Prefix。

例如:

```routeros
pppoe-129-1
```

作为全 LAN IPv6。

其它线路仅 IPv4 PCC。

这是运营级最稳定方案。

---

## 方案2(高阶)

使用:

* VRF
* DHCPv6-PD per VLAN
* policy route v6

但复杂度极高。

家庭 PCDN 不值得。

---

# 四、你缺少 DHCP Server Network

我发现你根本没写:

```routeros
/ip dhcp-server network
```

这会导致:

有些设备:

* 拿到 IP
* 没网关
* 没 DNS

或者:

* DHCP 偶尔失败

这是第二大问题。

你至少需要:

```routeros
/ip pool add name=lan_pool ranges=192.168.5.100-192.168.5.254

/ip address add address=192.168.5.1/24 interface=ether2

/ip dhcp-server add interface=ether2 address-pool=lan_pool name=lan_dhcp

/ip dhcp-server network add \
address=192.168.5.0/24 \
gateway=192.168.5.1 \
dns-server=192.168.5.1
```

否则 DHCP 不完整。

---

# 五、你的 LAN 内网互通规则实际上不完整

你说:

5 网段
13 网段

互通。

但你实际上:

没创建 bridge。

也没:

forward accept。

你只有:

```routeros
LAN_All_Internal_Bypass
```

但:

这是 mangle accept。

不是 firewall filter accept。

如果 filter 默认 drop:

还是不通。

---

# 六、你缺少 MSS 修正

PPPoE + 多拨 必须:

```routeros
/ip firewall mangle add \
chain=forward \
protocol=tcp \
tcp-flags=syn \
action=change-mss \
new-mss=clamp-to-pmtu
```

否则:

* 某些 HTTPS 打不开
* 微信图片失败
* 请不要发布这类群,谢谢 卡顿
* Steam 登录失败

这也是很多“能 ping 不能上网页”的根源。

---

# 七、你的黑洞路由逻辑有风险

你:

```routeros
distance=250
```

问题是:

ROS v7 某些情况下:

动态路由消失后:

黑洞不会立即接管。

会短暂 fallback main。

导致:

流量串线。

---

# 更稳做法

用:

```routeros
check-gateway=ping
scope
target-scope
```

配合 recursive route。

运营级才稳定。

---

# 八、你缺少 PPPoE 自动重拨优化

建议:

```routeros
keepalive-timeout=30
```

并且:

```routeros
max-mtu=1480
max-mru=1480
```

某些运营商:

1492 不稳定。

尤其:

VLAN + macvlan + 多拨。

---

# 九、你的 MAC 地址有风险

你用了:

```routeros
00:00:00:00:00:A1
```

很多运营商:

直接判异常 MAC。

建议:

使用:

```routeros
02:xx:xx:xx:xx:xx
```

本地管理 MAC。

例如:

```routeros
02:11:22:33:44:51
```

---

# 十、你的 PCC 分类方式不适合 PCDN

你现在:

```routeros
both-addresses-and-ports
```

对于:

* BT
* QUIC
* PCDN

会导致:

连接漂移。

建议:

```routeros
both-addresses
```

稳定性更高。

---

# 十一、你现在最大架构问题

你想:

9拨:

* IPv4 PCC
* IPv6 全广播
* NAT1
* Full Cone
* PCDN

同时全开。

但实际上:

ROS 最稳定方案是:

# 生产级推荐:

## IPv4:

* 9拨 PCC
* NAT1
* Full Cone
* PCDN

## IPv6:

* 只给 LAN 广播一个 Prefix

这是最稳的。

否则:

IPv6 多 Prefix 下发一定出问题。

---

# 你这个脚本目前的完成度

我给你客观评价:

| 项目        | 水平    |
| --------- | ----- |
| 基础网络理解    | 很强    |
| ROS v7 理解 | 中高级   |
| PCC 理解    | 中高级   |
| IPv6 理解   | 有明显误区 |
| NAT1 理解   | 正确    |
| 容灾思路      | 正确    |
| 架构稳定性     | 不够    |
| 生产可用性     | 60分   |

但已经比网上 95% 的 ROS 多拨脚本强了。

尤其:

动态 Adaptive_Engine。

这个思路其实不错。

---

# 最终建议(非常重要)

你应该:

# 不要继续“AI 套 AI 修补”

因为:

ROS 多策略路由:

已经属于:

运营级网络工程。

AI 很容易:

* 规则顺序错
* connection-mark 泄漏
* main 表污染
* recursive route 死循环
* IPv6 RA 混乱

最后:

越修越乱。

---

# 正确路线

你应该:

# 先做稳定版:

## 第一阶段

只实现:

* 3拨
* IPv4 PCC
* DHCP
* NAT1
* 内网互通

先稳定。

---

## 第二阶段

再:

* IPv6 单 Prefix
* 动态重拨
* failover

---

## 第三阶段

最后:

* 多 IPv6 Prefix
* VRF
* 容器联动
* BFD
* ECMP

否则复杂度会爆炸。

---

你这个方案真正最致命的 bug:

就是:

PCC 后 routing-mark 没正确命中 LAN 流量。

这就是:

“DHCP 正常但不能上网”的核心根源。
只谈技术、莫论政事!(点击见详情) | 互相尊重、友善交流、切勿过度反应、玻璃心。胡乱输入灌水等操作将会被封禁ID。
回复

使用道具 举报

发表于 2026-5-24 06:44 | 显示全部楼层
别用国产ai

点评

说的对,TM的,我用了几次,就出几次错误。Z tmd的悔气。。现在小视频都调侃豆包  详情 回复 发表于 2026-5-28 20:07
只谈技术、莫论政事!(点击见详情) | 互相尊重、友善交流、切勿过度反应、玻璃心。胡乱输入灌水等操作将会被封禁ID。
回复

使用道具 举报

发表于 2026-5-28 20:07 | 显示全部楼层

说的对,TM的,我用了几次,就出几次错误。Z tmd的悔气。。现在小视频都调侃豆包
只谈技术、莫论政事!(点击见详情) | 互相尊重、友善交流、切勿过度反应、玻璃心。胡乱输入灌水等操作将会被封禁ID。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /2 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2026-8-23 17:09

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 电话:13506125623

快速回复 返回顶部 返回列表