v4/v6 双栈自动添加路由规则脚本,可在 /ppp/profiles 新建一个 profiles 在 on up 中填入,然后 pppoe 拨号时引入
```
{
:local ifc WZ-CTC-300M; # FIXME pppoe 接口
:local itb ctc; # FIXME 自定义路由表
:delay 3s;
:local ipv4 [/ip/address get [find interface=$ifc] address];
:local ipv6 [/ipv6/address get [find interface=$ifc and global] address];
:local ipv4 [:pick $ipv4 0 [:find $ipv4 "/"]]
:local ipv6 [:pick $ipv6 0 [:find $ipv6 "/"]]
:if ($ipv4 != "") do={
/routing/rule remove [find comment="$itb-v4"];
/routing/rule add action=lookup-only-in-table src-address=$ipv4 table=$itb comment="$itb-v4";
/routing/rule remove [find comment="$itb-v6"];
/routing/rule add action=lookup-only-in-table src-address=$ipv6 table=$itb comment="$itb-v6";
:put $ipv4; :put $ipv6;
:log warning "[redail] $ifc -- IP changed to $ipv4 / $ipv6";
} else={
:log warning "[redail] IP address not available. Redial may not have occurred.";
}
}
```
说明:
---------------
1 、以上脚本未经长时间测试,请谨慎修改使用
2 、其中 ipv6 部分为根据 prefix 在 pool 中手动分配,其它情况请酌情修改 (参考:
https://post.smzdm.com/p/aqm47w6p/)