找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1546|回复: 1

[脚本] 自动更改网关和防火墙地址

[复制链接]
发表于 2023-9-7 21:08:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
由于配置要求,无法设置添加默认路由=是。需要使用脚本来修改网关和防火墙地址列表。但是,以下脚本在运行时报告了错误。请大神帮忙看一看并修改它。谢谢。(7.10.2 版)


{
:local v6i "3"
:for v6ii from=1 to=$v6i do={
:local v6gateway [/ipv6 route get [/ipv6 route find comment=("pppoe-out".$v6ii)] gateway]
:set v6gateway [:pick $v6gateway 0 [:find $v6gateway "%"]]
:local v6adlist [/ipv6 firewall address-list get [/ipv6 firewall address-list find comment=("pppoe-out".$v6ii)] address]
:local v6ser [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface=("pppoe-out".$v6ii) dhcp-server-v6]
:local prefix [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface=("pppoe-out".$v6ii) prefix]
:if ($v6gateway != $v6ser) do={
/ipv6 route set [/ipv6 route find comment=("pppoe-out".$v6ii)] gateway=($v6ser."%".("pppoe-out".$v6ii))}
:if ($v6adlist != $prefix) do={
/ipv6 firewall address-list set [/ipv6 firewall address-list find comment=("pppoe-out".$v6ii)] address=$prefix}

}





ipv6 dhcp-client.png
ipv6 route.png
ipv6 firewall address-list.png
routeros
发表于 2024-1-6 23:32:21 | 显示全部楼层
  1. :local i [/ipv6 dhcp-c find interface="pppoe-out1"]
  2. :local j [/ipv6 firewall address-list find list="LOCAL_IP" comment="pppoe-out1"]
  3. :local k [/ipv6 route find gateway~"%fe80" comment="pppoe-out1"]

  4. :local pf [/ipv6 dhcp-c get $i prefix]
  5. :local gw "$[/ipv6 dhcp-c get $i dhcp-server-v6]%pppoe-out1"

  6. :local addr [/ipv6 firewall address-list get $j address]
  7. :local rgw [/ipv6 route get $k gateway]

  8. :if ($addr!=$pf) do={/ipv6 firewall address-list set $j address=$pf}
  9. :if ($rgw!=$gw) do={/ipv6 route set $k gateway=$gw}
复制代码
routeros
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-12-4 16:01 , Processed in 0.046692 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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