蓝色动力网络

 找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2740|回复: 1

ROS中ADSL叠加脚本

[复制链接]
发表于 2010-8-24 09:22:06 | 显示全部楼层 |阅读模式
  1. w ""
  2. :local js 0
  3. :foreach k in=[/inter pppoe-c find running=false] do={
  4. :set n [/inter pppoe-c get $k name]
  5. :set ipi [/ip addr find interface=$n dynamic=false]
  6. :if ($ipi != "") do={/ip addr remove $ipi}
  7. }
  8. :foreach k in=[/inter pppoe-c find running=true] do={
  9. :set n [/inter pppoe-c get $k name]
  10. :set dip [/ip address get [find interface=$n dynamic=true] address]
  11. :set diip [:pick $dip 0 [:find $dip /]]
  12. :if ($js=0) do={:set gw $diip} else={:set gw ($gw . "," . $diip)}
  13. :set js ($js+1)
  14. :set ipi [/ip addr find interface=$n dynamic=false]
  15. :if ($ipi="") do={/ip addr add address=$diip netmask=255.255.255.255 network=$diip broadcast=$diip interface=$n} else={
  16. :set sip [/ip addr get $ipi address]
  17. :set siip [:pick $sip 0 [:find $sip /]]
  18. :if ($diip != $siip) do={
  19. /ip addr set $ipi addr=$diip netmask=255.255.255.255 network=$diip broadcast=$diip
  20. }
  21. }
  22. }
  23. :set i [/ip route find comm=xiaobo]
  24. :if ($gw = "") do={:if ($i != "") do={/ip route remove $i}} else={
  25. :if ($i="") do={/ip route add gateway $gw comment=xiaobo} else={
  26. :set ogw [/ip route get $i gateway]
  27. :if ($ogw != $gw) do={/ip route set $i gateway $gw}
  28. }
  29. 加入防adsl掉线脚本
  30. :local assign-address
  31. :local new-address
  32. :local status
  33. :local x
  34. :set x 2
  35. :for i from=1 to=$x do={
  36.     :set status [/interface get [/interface find  name=("pppoe-out" . $i)] running]
  37.     :if ($status=true) do={
  38.      :set new-address [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
  39.      :set new-address [:pick $new-address 0 ([:len $new-address] -3)]
  40.      :set assign-address [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
  41.      :set assign-address [:pick $assign-address 0 ([:len $assign-address] -3)]
  42.         :if ($assign-address != $new-address) do={ /ip address set [/ip address find comment=$i] address=$new-address network=$new-address broadcast=$new-address
  43.         /ip route set [/ip route find comment=$i] gateway=$new-address
  44.         /ip fir nat set [/ip fir nat find comment=$i] to-addresses=$new-address
  45.         /ip route set [/ip route find comment=$i] gateway=$new-address
  46.        }
  47.    }
  48. }
  49. ip
  50. /ip address add address=192.168.5.1/255.255.255.0 interface=lan comment=lan
  51. /ip dns set primary-dns=202.102.224.68 secondary-dns=202.102.227.68 allow-remote-requests=yes
  52. /ip firewall mangle add chain=forward protocol=tcp tcp-flags=syn action=change-mss new-mss=1448
  53. /interface pppoe-client add name="pppoe-out1" interface=wan1 user="1" password="1" add-default-route=no disabled=no
  54. /interface pppoe-client enable pppoe-out1
  55. /ip address add address=58.58.58.1/32 interface=pppoe-out1 comment="1"
  56. /ip route add gateway=58.58.58.1 routing-mark=1 comment="1"
  57. /ip firewall mangle add chain=prerouting in-interface=lan connection-state=new nth=1,1,0 action=mark-connection new-connection-mark=1 passthrough=yes disabled=no
  58. /ip firewall mangle add chain=prerouting in-interface=lan connection-mark=1 action=mark-routing new-routing-mark=1 passthrough=no disabled=no
  59. /ip firewall nat add chain=srcnat connection-mark=1 action=src-nat to-addresses=58.58.58.1 to-ports=0-65535 comment="1" disabled=no
  60. /interface pppoe-client add name="pppoe-out2" interface=wan2 user="2" password="2" add-default-route=no disabled=no
  61. /interface pppoe-client enable pppoe-out2
  62. /ip address add address=58.58.58.2/32 interface=pppoe-out2 comment="2"
  63. /ip route add gateway=58.58.58.2 routing-mark=2 comment="2"
  64. /ip firewall mangle add chain=prerouting in-interface=lan connection-state=new nth=1,1,1 action=mark-connection new-connection-mark=2 passthrough=yes disabled=no
  65. /ip firewall mangle add chain=prerouting in-interface=lan connection-mark=2 action=mark-routing new-routing-mark=2 passthrough=no disabled=no
  66. /ip firewall nat add chain=srcnat connection-mark=2 action=src-nat to-addresses=58.58.58.2 to-ports=0-65535 comment="2" disabled=no
复制代码
发表于 2010-8-31 15:12:27 | 显示全部楼层
谢谢~~~~~~~~~~~~~~~~~~~
回复 支持 反对

使用道具 举报

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

本版积分规则

蓝色动力网络微信平台
网站管理,业务合作联系邮箱: admin#lansedongli.com    QQ:13412492 限网站业务问题.
网站帐号、密码、密保找回请使用注册邮箱,发送邮件至 password#lansedongli.com ,否则不予受理.
免责声明:本论坛所有文字和图片仅代表其个人观点.
本站某些资料或文章来自于互联网,不代表本站观点,如果侵犯了您的权益,请来信告知,我们会在三天内删除.
为了给大家一个更好的交流场所,请勿在本论坛发表与中华人民共和国法律相抵触的言论,请合作,谢谢!
Copyright © 2007-2019 Corporation Powered by网吧系统 版权所有    转载请注明!
浙ICP备11043737号 程序:Discuz! x3.4

湘公网安备 43018102000145号

手机版|Archiver|蓝色动力网络   

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