Jump to content
Калькуляторы

Помогите Не работает скрипт

Решил переделать этот скрипт на три канала.

 

:local pingcount 3

:local checkip 212.122.1.2

:local ipA 192.168.2.3

:local GatewayA 192.168.2.1

:local ipB 172.16.2.5

:local GatewayB 172.16.2.4

ip route add gateway=$GatewayA dst-address=$checkip comment="check"

:local pingresultA [/ping $checkip src-address=$ipA count=$pingcount]

ip route remove [find comment=check]

 

ip route add gateway=$GatewayB dst-address=$checkip comment="check"

:local pingresultB [/ping $checkip src-address=$ipB count=$pingcount]

ip route remove [find comment=check]

 

:if (($pingresultA=pingcount) && ($pingresultB=pingcount)) do={ip route set [find comment=Default Gateway] gateway=192.168.2.1,172.16.2.4}

:if (($pingresultA=pingcount) && ($pingresultB=0)) do={ip route set [find comment=Default Gateway] gateway=$pingresultA}

:if (($pingresultA=0) && ($pingresultB=pingcount)) do={ip route set [find comment=Default Gateway] gateway=$pingresultB}

 

Вот что получилось (не работает)

:local pingcount 3

:local hostping ya.ru

:local ipA 192.168.10.4

:local GatewayA 192.168.10.1

:local ipB 192.168.20.4

:local GatewayB 192.168.20.1

:local ipC 195.238.100.86

:local GatewayC 195.238.100.85

 

ip route add gateway=$GatewayA dst-address=$hostping comment="check"

:local pingresultA [/ping $hostping src-address=$ipA count=$pingcount]

ip route remove [find comment=check]

 

ip route add gateway=$GatewayB dst-address=$hostping comment="check"

:local pingresultB [/ping $hostping src-address=$ipB count=$pingcount]

ip route remove [find comment=check]

 

ip route add gateway=$GatewayC dst-address=$hostping comment="check"

:local pingresultC [/ping $hostping src-address=$ipC count=$pingcount]

ip route remove [find comment=check]

 

:if (($pingresultA=pingcount)&&($pingresultB=pingcount)&&(pingresultC=pingcount)) do={ip route set [find comment=Default Gateway]gateway=192.168.10.1,192.168.20.1,195.238.100.85}

:if (($pingresultA=pingcount)&&($pingresultB=0)&&(pingresultC=pingcount)) do={ip route set [find comment=Default Gateway] gateway=192.168.10.1,195.238.100.85}

:if (($pingresultA=0)&&($pingresultB=pingcount)&&(pingresultC=pingcount)) do={ip route set [find comment=Default Gateway] gateway=192.168.20.1,195.238.100.85}

:if (($pingresultA=pingcount)&&($pingresultB=pingcount)&&(pingresultC=0)) do={ip route set [find comment=Default Gateway]gateway=192.168.10.1,192.168.20.1}

:if (($pingresultA=0)&&($pingresultB=0)&&(pingresultC=pingcount)) do={ip route set [find comment=Default Gateway] gateway=$195.238.100.85}

:if (($pingresultA=0)&&($pingresultB=pingcount)&&(pingresultC=0)) do={ip route set [find comment=Default Gateway] gateway=$192.168.20.1}

:if (($pingresultA=pingcount)&&($pingresultB=0)&&(pingresultC=0)) do={ip route set [find comment=Default Gateway] gateway=$192.168.10.1}

Edited by lk108

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this