I am new at scripting, and have what I believe is a small problem.
Pseudo code:
If wlan1 is enabled, do nothing and exit script
else enable wlan1 and exit script
Basically, I do not want to just enable everytime the script runs, because if wlan1 is enabled, and the script enables again, it breaks the link for about 2 seconds as it disconnects and reconnects.
/ip route set [find comment="Group B"] gateway=10.254.254.255;
I would like that command above to first check if /ip route [find comment=“Group B”] gateway=10.254.254.250 and if this is so, then run:
/ip route set [find comment="Group B"] gateway=10.254.254.255;
otherwise do nothing…
This is used as part of a load balancing/failover script, the two gateways being defaulted to 10.254.254.250 (GroupA) and 10.254..254.255 (GroupB), and only if one gateway goes down, then both groups are routed to the remaining “open” gateway.
Maybe I am not following, this will change any gw with 250 to 255, then both load groups go via gw 255. Now can not separate them again, as they identical Both gateways area active (load balancing), unless one falls over then, the failed GW is routed to the remaining active gateway, which is why I thought searching it on the “Comment” or maybe even “routing mark” field would be the easiest…
If the changes are made purely on the GW IP address, once they are the same, will never be able to separate them. Maybe routing mark as the selection field?
What I am trying to accomplish is via the netwatch on GroupB, once it comes up, from a down situation, the script must test if it is set at 255 or 250. If it is 255, then do nothing, if group B is 250 and netwatch shows it is “up”, then set to 255. Hope this makes the intention clearer.
Please explain the “255?” ? It has been working for 3 months so far, could this be causing problems I am unaware of?
Often IP addresses that end in .255 are broadcast addresses and cannot be gateways. Yours might be OK since we don’t know the subnet mask of your IP address on that network.
My AP’s are configured with IP addresses as per image below…
Each Client unit has a different network (and the same broadcast) setting, and on the Client Unit, the IP is set with the network and broadcast the same as the AP IP address, so effectively each client has it’s own network. 255 is never used on the wireless network as a common broadcast IP.
The Client unit associated with the first IP in the image above, has these settings for it’s IP’s…
I am trying to use this script to check two-parameter but it just executes without any action.
:foreach i in=[ip firewall nat find action=masquerade chain=srcnat src-address-list=no dst-address-list=no ] do={/ip firewall nat set src-address-list=AllowedSrc dst-address-list=AllowedDst}
I’d like to check inside of my NAT if the “src-address-list & dst-address-list” exist do nothing and IF they are not specified and not exist add “src-address-list=AllowedSrc” & dst-address-list=AllowedDst
I would be very grateful if someone helps me with this issue.
Many thanks for your response, Unfortunately, it didn’t solve the issue.
If I use below script I have to add number but I cant because I have many Mikrotik routers with several NAT I have to add src and dst address list by one script.
:if [/ip firewall nat find action=masquerade chain=srcnat] do={/ip firewall nat set src-address-list=“AllowedSrc” dst-address-list=“AllowedDst”}
Dear msatter,
BINGO!!! That is a good solution and answered. Thanks a million for your idea. It helps me a lot.
But the point is that it set src-address-list=AllowedSrc and dst-address-list=AllowedDst for all the existed NAT. I have several NAT which one of them should be changed and I am searching for somthing that compare and check the parameters and at last change as my need.