风一样的男孩 发表于 2010-8-24 09:22:06

ROS中ADSL叠加脚本


w ""
:local js 0
:foreach k in= do={
:set n
:set ipi
:if ($ipi != "") do={/ip addr remove $ipi}
}
:foreach k in= do={
:set n
:set dip address]
:set diip [:pick $dip 0 [:find $dip /]]
:if ($js=0) do={:set gw $diip} else={:set gw ($gw . "," . $diip)}
:set js ($js+1)
:set ipi
:if ($ipi="") do={/ip addr add address=$diip netmask=255.255.255.255 network=$diip broadcast=$diip interface=$n} else={
:set sip
:set siip [:pick $sip 0 [:find $sip /]]
:if ($diip != $siip) do={
/ip addr set $ipi addr=$diip netmask=255.255.255.255 network=$diip broadcast=$diip
}
}
}
:set i
:if ($gw = "") do={:if ($i != "") do={/ip route remove $i}} else={

:if ($i="") do={/ip route add gateway $gw comment=xiaobo} else={
:set ogw
:if ($ogw != $gw) do={/ip route set $i gateway $gw}

}


加入防adsl掉线脚本
:local assign-address
:local new-address
:local status
:local x
:set x 2
:for i from=1 to=$x do={
    :set status running]
    :if ($status=true) do={
     :set new-address address]
     :set new-address [:pick $new-address 0 ([:len $new-address] -3)]
     :set assign-address address]
     :set assign-address [:pick $assign-address 0 ([:len $assign-address] -3)]
        :if ($assign-address != $new-address) do={ /ip address set address=$new-address network=$new-address broadcast=$new-address
        /ip route set gateway=$new-address
        /ip fir nat set to-addresses=$new-address
        /ip route set gateway=$new-address
       }
   }
}
ip

/ip address add address=192.168.5.1/255.255.255.0 interface=lan comment=lan
/ip dns set primary-dns=202.102.224.68 secondary-dns=202.102.227.68 allow-remote-requests=yes
/ip firewall mangle add chain=forward protocol=tcp tcp-flags=syn action=change-mss new-mss=1448
/interface pppoe-client add name="pppoe-out1" interface=wan1 user="1" password="1" add-default-route=no disabled=no
/interface pppoe-client enable pppoe-out1
/ip address add address=58.58.58.1/32 interface=pppoe-out1 comment="1"
/ip route add gateway=58.58.58.1 routing-mark=1 comment="1"
/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
/ip firewall mangle add chain=prerouting in-interface=lan connection-mark=1 action=mark-routing new-routing-mark=1 passthrough=no disabled=no
/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
/interface pppoe-client add name="pppoe-out2" interface=wan2 user="2" password="2" add-default-route=no disabled=no
/interface pppoe-client enable pppoe-out2
/ip address add address=58.58.58.2/32 interface=pppoe-out2 comment="2"
/ip route add gateway=58.58.58.2 routing-mark=2 comment="2"
/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
/ip firewall mangle add chain=prerouting in-interface=lan connection-mark=2 action=mark-routing new-routing-mark=2 passthrough=no disabled=no
/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

amihot 发表于 2010-8-31 15:12:27

谢谢~~~~~~~~~~~~~~~~~~~
页: [1]
查看完整版本: ROS中ADSL叠加脚本