1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

On-the fly SSID change with CLI

Discussion in 'Tomato Firmware' started by wolfish, Dec 9, 2008.

  1. wolfish

    wolfish Addicted to LI Member

    Howdy,

    I'm trying to do some roaming tests and want to set up a remote script that will dynamically change the SSID for my clients, and I can't get the cli to cooperate.

    I've looked high and low through the forums and found some good info on changing the SSID through the command line, but it just won't work on the fly. I'm pretty sure I'm not restarting the right services in the right order like saving from the web GUI does.

    I've tried the following:

    -setting the ssid in nvram and commiting: No change in broadcasted SSID (a reboot does change it as expected, but I don't want to reboot.)

    -set wl ssid <name>, wl down, wl restart, wl up: this DOES change the broadcasted SSID, but security is busted

    -I've combined the two above, with no love

    -I've combined the 2, and thrown in some service restarts, but to no avail :(

    I'm not familiar eneogh with the interworkings of tomato to figure out just whats happening when one does a 'save' from the 'basic' page in the web UI.

    Any help on this would be greatly appreciated.

    Thanks!
     
  2. wolfish

    wolfish Addicted to LI Member

    Hrm. My last set of experiments seem to have hosed the WAN DHCP acquisition.

    FYI:

    wl down
    nvram set wl_ssid=DeadGateway3
    nvram commit
    wl ssid DeadGateway3
    wl restart
    wl up
    service net restart
    service wan restart


    Seems to make the router mad.
     
  3. wolfish

    wolfish Addicted to LI Member

    Perhaps I should rephrase...

    If anyone might be able to point me to a reference on the order of services that need to be restarted, or somewhere that might explain what happens when the 'save' button is clicked, I would be very grateful.

    I could do this automation through selenium I suppose, but that's just not as cool. ;)

    Thanks in advance!
     
  4. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    When that page is saved, a
    Code:
    kill -SIGHUP 1
    is run (will the c equivalent, at least). This restarts the init task (restarts all services), and has the same effect as running
    Code:
    rc restart
    . Most other pages just restart needed services, but, perhaps due to the troubles you've run into, this one restarts everything.

    Hope that helps.
     
  5. wolfish

    wolfish Addicted to LI Member

    Excellent, I'll give it a try.

    From the sounds of it though, that'd probably restart sshd. Hope not, because the save doesn't kill the ssh session, and for automation purposes, I'd need that to maintain.

    Anyways, thanks again for the suggestion, I'll update with results.
     
  6. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    I just tried it myself (both the kill and rc restart variety) and was able to continue my ssh session when the wireless came back up (obviously, I'm connected wirelessly). So, I think you're safe.
     
  7. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    I just looked a little deeper and the SIGHUP (though using the rc restart form would probably be cleaner for your script) results in restart (all stopped, then all started) of the following services:
    • smbd
    • sched
    • rstats
    • upnp
    • cron
    • httpd
    • cifs
    • dnsmasq
    • zebra
    • nas
    • usbevent
    • syslog
    • wan
    • lan
    • vlan

    So, yes, sshd remains running throughout (though you will lose connectivity to it for a moment).
     
  8. wolfish

    wolfish Addicted to LI Member

    SgtPepper, you're a king!

    It works like a champ, and the end code will only be 3 lines:

    nvram set wl_ssid=DeadGateway3
    nvram commit
    rc restart


    -Time for the commands to complete ~10 sec
    -Time for a Vista client to reassociate ~30 sec (starting script to reassc)

    My putty session persists without an issue, hopefully the perl script will be the same.

    Thanks again for the help!
     
  9. sunjon

    sunjon Network Guru Member

    SgtPepperSKU: smbd? :)
     
  10. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    Yep, it's part of the list. But, of course, it is only restarted if it is compiled in, which it is not. The same goes for usbevent.

    They both are conditional in the Tomato source, but (probably for good reason) they are not enabled by default (or even an option in the router menuconfig).
     
  11. jackocurly0074

    jackocurly0074 Networkin' Nut Member

    Realise this is an old thread, but thought it might be useful for anyone wanting to know!

    You should be able to change the SSID using the following commands -

    wl ssid <new_ssid_name>
    nvram set wl_ssid=DeadGateway3
    nvram commit

    You should also run the nvram commands to ensure that the new data is saved to memory for the next time the device is rebooted. This should save having to continually reboot the device and will be quicker !

    Edit: This at least works on my router, WRT54GL and there is no need to run the wl restart / up/ down command etc. Running the following might also be worth a try for those who are having similar issues to the op -

    wl radio off
    wl radio on
     

Share This Page