правка Скрипту
-
Зараз на сторінці 0 користувачів
Немає користувачів, що переглядають цю сторінку.
-
Схожий контент
-
Від omvk
Доброго времени суток уважаемые форумчане! Не являюсь знатаком языка скриптов Mikrotik потому прошу помощи у ГУРУ. Дело в том что ниже приведенный скрипт был написан в пору прошивки routeros-mipsbe-6.42.7. На современных прошивках сыплет еррорами. Прошу, кому не в лом поправить....с меня ПИВО!
:global ppp1 {"konamy";"dev1";"XXXXXXXXXX";"192.64.7.22/24";"172.65.130.96/27";"10.65.7.60/30"}
:global ppp2 {"konamy";"dev2";"XXXXXXXXXX";"192.64.7.23/24";"172.65.130.128/27";"10.65.7.64/30"}
:global ppp3 {"konamy";"dev3";"XXXXXXXXXX";"192.64.7.24/24";"172.65.130.160/27";"10.65.7.68/30"}
:global ppp4 {"konamy";"dev4";"XXXXXXXXXX";"192.64.7.25/24";"172.65.130.192/27";"10.65.7.72/30"}
:global ppp5 {"konamy";"dev5";"XXXXXXXXXX";"192.64.7.26/24";"172.65.130.224/27";"10.65.7.76/30"}
:global config $ppp5
:global proposalNAME "proposal-sha1-aes256-grp5"
:global ipsecSECRET "XXXXXXXXXXXXXXXXX"
:global areaNAME "area1000"
:global COUNTRY "Ukraine"
:global areaID "11.7.0.0"
:global costGRE "25"
:global sysver [/system package get system version]
/system ntp client set enabled=yes primary-ntp="172.64.0.1"
/system clock set time-zone-name=Europe/Kiev
/ip firewall {
:local o [nat find comment="defconf"]
:if ([:len $o] != 0) do={ nat disable $o }
:local o [filter find comment="defconf"]
:if ([:len $o] != 0) do={ filter remove $o }
}
/ip dhcp-server network {
:local o [find comment="defconf"]
:if ([:len $o] != 0) do={ remove $o }
}
/ip dhcp-server {
:local o [find name="defconf" ]
:if ([:len $o] != 0) do={ disable $o }
}
/ip pool {
:local o [find name="default-dhcp"]
:if ([:len $o] != 0) do={ remove $o }
}
/ip address {
:local o [find comment="defconf"]
:if ([:len $o] != 0) do={ disable $o }
}
######################################################################################
:for i from=1 to=[/ip firewall filter print count] do={/ip firewall filter disable $i}
:for i from=0 to=[/ip firewall nat print count] do={/ip firewall nat disable $i}
:global iptmp
:global ipCONF do={
:global mask "255.255.255.255"
:local startIP "0"
:local endIP "2"
:global ip [:pick $iptmp 0 [:find $iptmp "/"]]
:global prefix [:pick $iptmp [:find $iptmp "/"] [ :len $iptmp]]
:if ($prefix="/24") do={ :set mask "255.255.255.0"; :set startIP 12; :set endIP 254 }
:if ($prefix="/25") do={ :set mask "255.255.255.128"; :set startIP 10; :set endIP 126 }
:if ($prefix="/26") do={ :set mask "255.255.255.192"; :set startIP 8; :set endIP 62 }
:if ($prefix="/27") do={ :set mask "255.255.255.224"; :set startIP 6; :set endIP 30 }
:if ($prefix="/28") do={ :set mask "255.255.255.240"; :set startIP 4; :set endIP 14 }
:if ($prefix="/29") do={ :set mask "255.255.255.248"; :set startIP 1; :set endIP 6 }
:if ($prefix="/30") do={ :set mask "255.255.255.252"; :set startIP 0; :set endIP 2 }
:global network ($ip&$mask)
:global poolSTART ($network+$startIP)
:global poolEND ($network+$endIP)
}
:global ORG ($config->0)
:global UNIT ($config->1)
:global GrePSWD ($config->2)
:global intCOUNT ([/interface ethernet print count-only])
$ipCONF iptmp=($config->3)
:global ether1NAME [/interface ethernet get [ find default-name="ether1" ] name ]
:global ether1 {ip="$ip";netmask="$prefix";gateway=($network+3)}
$ipCONF iptmp=($config->4)
:global lanNAME [/ip dhcp-server get [find] interface]
:global lan {ip=($network+1);netmask="$prefix";network="$network";pool="$poolSTART-$poolEND"}
$ipCONF iptmp=($config->5)
:global greNAME "gre-$ORG"
:global gre {ip=($network+2);netmask="$prefix";network="$network"}
:global ether1IP ($ether1->"ip")
:global ether1MASK ($ether1->"netmask")
:global ether1GATEWAY ($ether1->"gateway")
:global lanIP ($lan->"ip")
:global lanMASK ($lan->"netmask")
:global lanNET ($lan->"network")
:global lanPOOL ($lan->"pool")
:global greIP ($gre->"ip")
:global greMASK ($gre->"netmask")
:global greNET ($gre->"network")
:global greSRCIP ($ether1->"ip")
:global greDSTIP ($ether1->"gateway")
#:set greDSTIP $greSERVERIP
/system identity set name="$UNIT"
/interface gre {
remove [find name="$greNAME"]
add !keepalive mtu=1400 name="$greNAME" local-address="$greSRCIP" remote-address="$greDSTIP"
}
/ip address {
remove [find address="$lanIP$lanMASK"]
remove [find address="$ether1IP$ether1MASK"]
remove [find address="$greIP$greMASK"]
add address="$lanIP$lanMASK" interface="$lanNAME"
add address="$ether1IP$ether1MASK" interface="$ether1NAME"
add address="$greIP$greMASK" interface="$greNAME"
}
/ip route {
add distance=1 gateway="$ether1GATEWAY"
}
/ip dhcp-client {
set [find interface="$ether1NAME"] disable=yes
}
/ip pool {
remove [find name=default-dhcp]
add name=default-dhcp ranges="$lanPOOL" }
/ip dhcp-server {
remove [find name=default]
add address-pool=default-dhcp disabled=no interface="$lanNAME" lease-time=7d name=default }
/ip dhcp-server network {
remove [find address="$lanNET$lanMASK"]
add address="$lanNET$lanMASK" dns-server="172.64.0.4,10.0.2.2" gateway="$lanIP" }
/ip ipsec policy group {
remove [find name="gre"]
add name=gre }
/ip ipsec policy {
remove [find comment="Template GRE"]
add comment="Template GRE" group=gre protocol=gre template=yes
remove [find comment="$greNAME"]
add comment="$greNAME" sa-src-address="$greSRCIP" src-address="$greSRCIP" sa-dst-address="$greDSTIP" dst-address="$greDSTIP" protocol=gre disabled=no
}
/ip ipsec proposal {
remove [find name="$proposalNAME"]
add name="$proposalNAME" enc-algorithms=aes-256-cbc lifetime=1h pfs-group=modp1536 }
/ip ipsec peer {
remove [find comment="$greNAME"]
add comment="$greNAME" address="$greDSTIP" local-address="$greSRCIP" secret="$GrePSWD" generate-policy=port-strict policy-template-group="gre"
}
/routing ospf network {
remove [find comment=lan]
remove [find comment=gre] }
/routing ospf area {
remove [find name="$areaNAME"]
add area-id="$areaID" default-cost=1 inject-summary-lsas=no name="$areaNAME" type=stub }
/routing ospf network {
add area="$areaNAME" comment=lan network="$lanNET$lanMASK"
add area="$areaNAME" comment=gre network="$greNET$greMASK"
}
/routing ospf interface {
remove [find interface="all"]
add network-type=broadcast passive=yes
remove [find interface="$greNAME"]
add cost="$costGRE" interface="$greNAME" network-type=point-to-point
}
/system scheduler {
remove [find name=script1]
add interval=6h name=script1 on-event="/system script run [find name=script1]" start-date=jan/01/2016 start-time=12:00:00 }
:for i from=1 to=[/interface wireless print count] do={
/interface wireless set disabled=yes numbers=($i-1)
/interface bridge port remove [find interface=[/interface wireless get ($i-1) name]]
}
:for i from=1 to=[/interface bridge print count] do={/interface bridge set protocol-mode=none numbers=($i-1)}
/user set admin password="XXXXXXXXXX"
/file remove config.rsc
-
Від NETOS
Всем привет! Есть строка кода
BACKUP_NAME=`expr match "${TARGET_DIR%%/}" '.*/\(.*\)'`
вероятнее всего написанная для Debian. Не работает у меня во FreeBSD, пишет expr: syntax error
Помогите правильно параметры прописать.
Рекомендованные сообщения
Создайте аккаунт или войдите в него для комментирования
Вы должны быть пользователем, чтобы оставить комментарий
Создать аккаунт
Зарегистрируйтесь для получения аккаунта. Это просто!
Зарегистрировать аккаунтВхід
Уже зарегистрированы? Войдите здесь.
Войти сейчас