找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 10882|回复: 1

[脚本] 求助关于大猫猫脚本改进

[复制链接]
发表于 2019-7-12 23:03:54 | 显示全部楼层 |阅读模式

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

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

×
  • ###使用前请确保你当前没有使用穿透进行管理###  
  • ###请删除之前自己创建的CTS穿透VPN连接,方可使用本脚本。###  
  • ###建议5-10分钟循环执行一次。6.38.5测试通过。###  
  • ###定义CTS服务器IP###  
  • :global ctsip 120.24.176.137  
  • ###定义CTS服务器虚拟网关###  
  • :global ctsgw 172.34.56.1  
  • ###定义CTS服务器用户名###  
  • :global ctsuser "user"  
  • ###定义CTS服务器密码###  
  • :global ctspass "passwd"  
  • ###获取当前使用的CTS的VPN类型###  
  • :global usedvpn ""  
  • ###获取当前CTS连接状态###  
  • :global stvpn   
  • :if ([/interface pptp-client find name=CTS-PPTP]!="") do={  
  • :set usedvpn pptp  
  • :set stvpn [/interface pptp-client find name=CTS-PPTP running=yes]}  
  • :if ([/interface l2tp-client find name=CTS-L2TP]!="") do={  
  • :set usedvpn l2tp  
  • :set stvpn [/interface l2tp-client find name=CTS-L2TP running=yes]}  
  • :if ([/interface sstp-client find name=CTS-SSTP]!="") do={  
  • :set usedvpn sstp  
  • :set stvpn [/interface sstp-client find name=CTS-SSTP running=yes]}  
  • :if ([/interface ovpn-client find name=CTS-OVPN]!="") do={  
  • :set usedvpn ovpn  
  • :set stvpn [/interface ovpn-client find name=CTS-OVPN running=yes]}  
  • ###没有发现任何符合条件的穿透接口,我来创建一个###  
  • :if (usedvpn="") do={  
  • :if ([/interface pptp-client find connect-to=$ctsip]!="") do={  
  • /interface pptp-client set [find connect-to=$ctsip] name=CTS-PPTP  
  • :set usedvpn pptp}  
  • :if ([/interface l2tp-client find connect-to=$ctsip]!="") do={  
  • /interface l2tp-client set [find connect-to=$ctsip] name=CTS-L2TP  
  • :set usedvpn l2tp}  
  • :if ([/interface sstp-client find connect-to=($ctsip.":22")]!="") do={  
  • /interface sstp-client set [find connect-to=($ctsip.":22")] name=CTS-SSTP  
  • :set usedvpn sstp}  
  • :if ([/interface ovpn-client find connect-to=$ctsip]!="") do={  
  • /interface ovpn-client set [find connect-to=$ctsip] name=CTS-OVPN  
  • :set usedvpn ovpn}}  
  • :if (usedvpn="") do={/interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}  
  • ###检测CTS当前连接是否正常,不正常则切换VPN协议###  
  • :if ($stvpn="") do={  
  • :if ($usedvpn="pptp") do={  
  • /interface pptp-client remove [find name=CTS-PPTP]  
  • /interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}  
  • :if ($usedvpn="l2tp") do={  
  • /interface l2tp-client remove [find name=CTS-L2TP]  
  • /interface sstp-client  
  • add connect-to=($ctsip.":22") disabled=no name=CTS-SSTP profile=default-encryption user=$ctsuser password=$ctspass}  
  • :if ($usedvpn="sstp") do={  
  • /interface sstp-client remove [find name=CTS-SSTP]  
  • /interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}  
  • :if ($usedvpn="ovpn") do={  
  • /interface ovpn-client remove [find name=CTS-OVPN]  
  • #/interface pptp-client add connect-to=$ctsip name=CTS-PPTP user=$ctsuser password=$ctspass profile=default-encryption disabled=no  
  • /interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}  
  • } else={  
  • :if ([/ping $ctsgw count=4]=0) do={  
  • :if ($usedvpn="pptp") do={  
  • /interface pptp-client remove [find name=CTS-PPTP]  
  • /interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}  
  • :if ($usedvpn="l2tp") do={  
  • /interface l2tp-client remove [find name=CTS-L2TP]  
  • /interface sstp-client  
  • add connect-to=($ctsip.":22") disabled=no name=CTS-SSTP profile=default-encryption user=$ctsuser password=$ctspass}  
  • :if ($usedvpn="sstp") do={  
  • /interface sstp-client remove [find name=CTS-SSTP]  
  • /interface ovpn-client add cipher=aes128 connect-to=$ctsip port=110 name=CTS-OVPN user=$ctsuser password=$ctspass profile=default-encryption}  
  • :if ($usedvpn="ovpn") do={  
  • /interface ovpn-client remove [find name=CTS-OVPN]  
  • #/interface pptp-client add connect-to=$ctsip name=CTS-PPTP user=$ctsuser password=$ctspass profile=default-encryption disabled=no  
  • /interface l2tp-client add connect-to=$ctsip disabled=no name=CTS-L2TP user=$ctsuser password=$ctspass profile=default-encryption}  
  • }}  


以上为大猫猫原有脚本,我想增加多服务器,比如增加2或3台VPN服务器,自动PING,PING通或延时小的自动连接,每10分钟或30分钟检测一次,如果当前正常则不动,我自己在上面增加了,
{{
:if ([:ping count=4 1.1.1.1<1) do={
:global ctsip 1.1.1.1
:log info "使用1.1.1.1地址"
} else={
:global ctsip 2.2.2.2
:log info "使用2.2.2.地址"
}

增加这个代码以后执行不通过。想问问各位前辈如何更改。


routeros
 楼主| 发表于 2019-7-31 12:27:39 | 显示全部楼层
那些大神能指点一二啊,谢谢了。
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 08:40 , Processed in 0.095874 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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