I made a script, which is pinging over three different wan-interfaces. I had earlier the problem that I could not even ping the different interfaces separately. I found the solution to add vrfs like in the following picture:
After that I added different elements in the route list as in the following picture:
I am using the "vrf"-element in the ping tool to realize my Problem with pinging the different interfaces separately.
The following Code is the Script (gets scheduled every two seconds):
Code: Select all
:if ([/interface print count-only where name=lte1] = 1) do={
:global lte1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=lte1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
:global lte1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=lte1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
:if ([/interface print count-only where name=lte1] = 0) do={
/system/script/environment/remove lte1Ping;
/system/script/environment/remove lte1Status;
}
}
:if ([/interface wireless print count-only where name=[/interface wireless get [/interface wireless find where mode=station] name] running ] = 1) do={
:global wlan1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=wlan1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
:global wlan1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=wlan1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
:if ([/interface wireless print count-only where name=[/interface wireless get [/interface wireless find where mode=station] name] running ] = 0) do={
/system/script/environment/remove wlan1Ping;
/system/script/environment/remove wlan1Status;
}
}
:if ([/interface ethernet print count-only where name=ether1 running] = 1) do={
:global ether1Ping [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=ether1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"time")];
:global ether1Status [([:ping 8.8.8.8 vrf=[/ip/route/get [find where gateway=[/ip/route/get [find where vrf-interface=ether1] gateway] and routing-table!=main] routing-table] count=1 as-value]->"status")];
} else={
:if ([/interface ethernet print count-only where name=ether1 running] = 0) do={
/system/script/environment/remove ether1Ping;
/system/script/environment/remove ether1Status;
}
}
Sometimes I get timeouts as in the following picture and sometimes it gives me the right output:
The timeouts turning up for some seconds and go away again for some minutes.
Is this a normal behaviour? Do I used the right config? If not could someone tell me how to get it right? I do not want timeout if the interfaces are working correctly.
Every help is appreciated