I know there is a way to see what ssid is an interface connected to.
But, when we have 2 or more interfaces, how do you decide what interface is connected to what ?
I am using connect lists to connect to 2 ssid, from a mt box in station mode ( no wds ).
At the moment, I managed to do it by setting the same ip on the 2 distant ap’s, so as not to change the ip configuration of the station, as I don’t know to wich is connected.
What I would want to do:
Say there is AP1, ssid AP1, and AP2, ssid AP2. The addressing is different, say on the internal interfaces there is x.x.1.1 on AP1, and x.x.2.1 on AP2. Now, the station MUST change the ip address of itself, AND the default gateway, in order to reach internet access, and to be able to have it’s ip address routed.
Something like this:
am I connected on wlanx to AP1 ? → YES → Set public ip address x.x.1.10, default gw x.x.1.1
am I connected on wlanx to AP1 ? → YES → Set public ip address x.x.2.10, default gw x.x.2.1
am I disconnected from any AP ? → YES → take a break…
Anybody done that, or something similar, just to know how to determine to what ssid is one of the wireless interfaces connected to ? (note: there are multiple wireless interfaces on the station device).
and with script check ssid, if link ok, then stop, esle change ssid, so your client connects to other ap and gets ip address, netowrk settings and all.
:put [/in wireless get wlan1 running]
edit:
or just use connect-list feature where you can set up to what APs to connect to with that ssids
I did not thought about static dhcp yet, i did not want it enabled, but it’t actually the simplest solution…
I was still thinking to determine from a script to wich network am I linked with, and perform address changes and other actions too, trigered by the change. For example, there might be routes not available trough one link, disable them and activate redirect rules for the clients to go to one page explaining that, and so on.
well, if this is your local network and if it is you can route it. While this is doable with pure scripting i see no gain of doing that, due to simpler solution available out of the box. Just make sure your DHCP will not give out any other address, thats why i proposed that you make static lease for your client, as a resault, you don’t have to worry about a lot of things, thus reducing complexity of what you have to do with scripting, less problems if there are upgrade to scripting engine in routeros, that rarely but may occur.
Guess that’ll be it.
Anyway, if you can put a script wich writes in the log ( :log info "connected to x network, got ip x.x.x.x) it’l be fine.
( I did it in the first time with netwatch, enabling and disabling ip addreses, but now some are reachable trough multiple paths, so that would be more complicated)
yes, but you will see log entries only if “SOME_SSID” will be equal with “MY_SSID” and if it changed, you will see nothing in logs, while my version will show up every time ssid is changed between runs, because old ssid will be saved in global variable. what is closer to what you said in previous posts.
Yes, for log, i know the topic must be put. Just missed it.
For the script, it is perfectly acceptable, and there will be two checkings, meaning two if’s, to verify what I want.
Is there in the scripting something similar to the
DO CASE
CASE X
instructions
CASE Y
instructions
OTHER
default action
END CASE
?!?
If not, two if’s are acceptable, as for my specific case, they don’t impact that much on performance of this particular script.
For the script with $previousssid to work, I must know to WICH ssid am I connected with, not only that it has changed. There are routes in the back, it’s not wds, so addressing and the rest counts, in my case.
i told you, set up static dhcp for that client that may bounds from one AP to another, so when it is connected to one, it will get all the configuration needed, when switch over to other it will automatically receive configuration you need, so the hosts behind your client router will not see any changes at all.
otherway you need to use 2 ifs
first as already set, that will see if ssid changed, an the other one, to determin which ssid is currently active and then set appropriate settings. Of course, if ssid have not changed - you do not have to change anything.
and also, as you can see in script - previousssid is ssid that was set when script was running last time, and if it ahs changed, then current ssid is assigned to previoussid.