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

Script: Use web UI for Wireless params when WLAN not on br0

Discussion in 'Tomato Firmware' started by jmcafee, Jun 4, 2011.

  1. jmcafee

    jmcafee Addicted to LI Member

    Your custom configuration may disconnect the WLAN from br0, such as for isolated guest wireless access. The web UI no longer functions to set the wireless security parameters, requiring hand coding a command line script to pass them to the authentication binary.

    With this script you can set your parameters via the web UI, just as if the WLAN was still on br0. The script parses the variables set in the web UI, and constructs a command line to pass them to the authentication binary.

    Place this in the Admin/Scripts/Init. Copy the code carefully as the 'nas' command line is long.

    Tested with Tomato 1.28, WRT54G/GL.

    # The following passes the security settings set in the web UI to the binary module 'nas'.
    # Parameters include WPA share-key, SSID, encryption mode, 
    # authentication mode, and WPA key renewal. The script isn't written to pass all
    # of the necessary parameters required for RADIUS enabled modes.
    # Assumes the WLAN (eth1) is on br1.
    if [ `nvram get wl0_radio` = 1 ]; then 	# do only if radio is on
    	# set nas m param
    	case "`nvram get wl0_akm`" in
    		"wpa") tempvar_wl_auth=2;;      # RADIUS
    		"psk") tempvar_wl_auth=4;;
    		"802.1x") tempvar_wl_auth=32;;  # RADIUS
    		"wpa2") tempvar_wl_auth=64;;    # RADIUS
    		"wpa wpa2") tempvar_wl_auth=66;;  # RADIUS
    		"psk2") tempvar_wl_auth=128;;
    		"psk psk2") tempvar_wl_auth=132;;
    		*) tempvar_wl_auth=0;;	# security is disabled or unrecognized
    	# set nas w param
    	case "`nvram get wl0_crypto`" in
    		"wep") tempvar_wl_crypto=1;;
    		"tkip") tempvar_wl_crypto=2;;
    		"aes") tempvar_wl_crypto=4;;
    		"tkip+aes") tempvar_wl_crypto=6;;
    		*) tempvar_wl_crypto=0;;     # encryption is disabled or unrecognized
    	# pass the params
    	if [ $tempvar_wl_auth != 0 ]; then
    		if [ $tempvar_wl_crypto != 0 ]; then
    		    killall -9 nas		
    		    nas -P /var/run/nas.pid -l br1 -H 34954 -i eth1 -A -m $tempvar_wl_auth -k "`nvram get wl0_wpa_psk`" -s "`nvram get wl0_ssid`" -w $tempvar_wl_crypto -g `nvram get wl0_wpa_gtk_rekey`

Share This Page