Posts Tagged mikrotik routeros

ros脚本记录1

Posted by on 星期三, 19 五月, 2010

  自已用的ros脚本,记录一下。

:global username username

:global password password

:global domainname "wolf"

:global domainzone "dnsrd.com"

:if ([/interface find type=pppoe-out running=yes]="") do={

:beep frequency=500 length=2s

:delay 4

:beep frequency=500 length=2s

:log warning "DDNS: No PPPoE is running."

} else={

:global intLocal [ /interface get [ /interface find type=pppoe-out running=yes ] name ]
:global ipResolve ([:resolve ($domainname . "." . $domainzone)] . "/32")
:global ipLocal [ /ip address get [ /ip address find interface=$intLocal ] address ]

:if ($ipLocal != $ipResolve) do={

:log info ("DDNS: Resolved IP address : " . $ipResolve )

:log info ("DDNS: Local IP address : " . $ipLocal )

:log info ("DDNS: Sending Dynamic DNS update to server")

/tool dns-update zone=$domainzone name=$domainname key=$password key-name=$username address=[:pick $ipLocal 0 ([:len $ipLocal] - 3)]

/tool dns-update zone="changeip.com" name="wolf" key=****** key-name="******" address=[:pick $ipLocal 0 ([:len $ipLocal] - 3)]

/tool dns-update zone="changeip.com" name="wolf" key=****** key-name="******" address=[:pick $ipLocal 0 ([:len $ipLocal] - 3)]

/ip upnp set enabled=no
:foreach i in=[/ip upnp interfaces find disabled=no ] do={/ip upnp interfaces remove $i}
/ip upnp interfaces add interface=[/interface get [/interface pppoe-client find running=yes ] name] type=external

/ip upnp interfaces add interface=LAN type=internal

/ip upnp set enabled=yes

/ip upnp set allow-disable-external-interface=no

/ip upnp set show-dummy-rule=yes

/ip firewall mangle set [find comment="flowback"] dst-address=[/ip address get [find interface=WAN ] address ]

/interface 6to4 set sit1 local-address=[:pick $ipLocal 0 ([:len $ipLocal] - 3)]

:beep frequency=500

:log info "All Done!"

}

}