Switching configs

I want to use my GL.iNet 6416 to serve as an Access Point with all traffic going over OpenVPN back to my home network. I added a RT5370 802.11n usb adapter for a second radio and created 2 different configurations:

  1. ‘Universal Repeater’ connecting as wireless client to hotel wifi on radio0, and acting as AP on radio1. I connect with laptop/phone to AP, connect to hotel wifi using Luci, and get past any browser based Welcome screen. This registers the radio0 MAC with the hotel AP.

  2. Second configuration is similar to the first but with firewall rules to redirect all traffic over OpenVPN client.

Currently I’m using the luci config backup/restore to switch between configs stored on my laptop.

Can anyone recommend a better way of doing this? Perhaps storing the configs on the 6416 and switching using the reset button, or maybe extending Luci somehow to run scripts. I’m sure it must be a common problem.

Thanks

Craig

I wrote a /etc/rc.button/reset script to switch the configs so I think thats good for now.

Unrelated: The LED is blank when I have radio0 as wireless client and radio1 as AP. Everything works fine but it looks like the device is off. Is it possible to make the LEDs flash like they do when radio0 is in AP mode?

Thanks

Craig

 

Switch config … Super. I think this is BIG!

Can you please document the setup for the storing the alternate configs and your scripts for the switch function? I would like to to something very similar.

Also, what are you using for the second USB device, and what driver(s) go with it?

Thanks… RangerZ

I’m an OpenWRT noob so I’m apprehensive to post my hacked up /etc/rc.button/reset script which is probably full of bad examples of how not to do things. That said, it seems to work fine for my purposes. Is there a way I could send it to you directly?

For radio1 I am using a $4 RT5370 usb dongle[link]. I bought this a years ago and it looks like the new ones might not have the same chipset so best to get one that explicitly state RT5370[link].

I think with 2.14 firmware the drivers might be there by default. I have a bunch of other usb stuff so here are the usb related packages I installed…

opkg install kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether usbutils udev
opkg install kmod-usb-net-dm9601-ether kmod-usb-net-asix kmod-zd1211rw
opkg install kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb

 

One of the benefits of the open source community is getting help and learning from others. If you have borrowed the code, just give credit to the original author. Hacked\crude or just bad, someone else may be able to help improve it.

As for the dongle, info on these is not compiled in any good format anywhere. I have used and EDIMAX 7811 which works great in my laptop, but marginal in my router. My Bufflo WLI-UC-GN works much better.

I assume that you are using a second radio to avoid the WAN hang issue. You may want to review this post and related OpenWrt links. 404 Page not found - GL.iNet One of the tools, deletes the WAN. I have it working on an AR150 on the reset button, as opposed to the switch. You just need to be aware that the LAN is the wifi-iface[0], after using it, not wifi-iface[1] like default.

Its not borrowed - just hacky. See attached.

I created 3 backups via luci, uploaded them to /root/ dir on the router and created symbolinks called config0.tar,gz, config1.tar,gz and config2.tar.gz that the script cycles through. It attempts to keep the wireless config between reboots unless the radio0 is not enabled in sta mode - this is so my usb tethered config works. Im using a Repeater config, Repeater over OpenVPN, and Tethered over OpenVPN configs (ZTE z915).

 

can you just change file extension to .txt?

.txt worked - Thanks.

Any suggestions on how to configure radio1 to flash the led like radio0 does?

Hi, some comments on your script:

1.

Line 13 to 31, you are finding the radio0 sta iface, I’d rather just write one loop to do this. Go through $N=1 to 5 and find the “device=radio0” and “mode=sta”. This will be much clear.

2.

Line 33, you can just use “uci” to get if the interface is disabled, which will be much clear. Set a name for your sta wireless interface, like the following:

config wifi-iface ‘sta’
option device radio0
option mode ‘sta’
option disabled ‘1’
The use “uci get wireless.sta.disabled” to check if it is diabled.

3.

You are backing up the whole /etc/config/wireless file, which I think no good. Because the file may contains some other info that you didn’t want to reserve.

Just set the appropriate values. I think the values you are trying to reserve is ssid, channel, password, encryption, key, just store them in one file, for example, write another /ect/config/wireless_parameters file, and get these values by uci.

4.

I am not very clear of your logic to back up and restore configurations. Seems you stores many configurations and indicate them by flashing the LED a number of times. are you just restoring the last config?

Everytime when you trigger the script the router reboots. this could be last long. You can just reset the wireless or whole network.

reset wireless: execute “wifi”

reset network, execute “/etc/init.d/network restart”

 

 

Yes, I did mention it was pretty hacky - I just kept adding stuff :slight_smile:

Some explanation:

  1. When switching between my Repeater config and my Repeater+OpenVPN config I want to keep the radio0 client-wireless and radio1 AP settings when I switch. I noticed /etc/config/wireless was the same for both so I just backed it up and restored after untarring the new config. This worked until I added a config which used a usb tethered ZTE Z915 LTE modem rather than client-wireless. When I switched to that config the restored <span style=“line-height: 1.5;”>/etc/config/wireless would make OpenWRT connect via wifi and not use the modem so I added more logic to only overwrite </span><span style=“line-height: 1.5;”>/etc/config/wireless if the new version had client-wireless enabled.</span>

  2. I wasn’t sure the exact ‘uci get’ I need to find if ‘wwan’ was disabled and I was configuring everything via luci and didnt notice an option to add a name. I could edit the config manually to add the name but would it get preserved if I change things via luci?

  3. Yes, backing up the whole file is not great, however I always have the same AP config on radio1 so its just the client-wireless setting on radio0 that change. I couldn’t think of an easy way to isolate all the sections and options I would need to preserve from /etc/config/wireless so I just preserve the whole file. I was also worried that luci might create new client-wireless options that I don’t expect about when I scan/connect manually.

  4. I was creating several numbered configurations ( /root/config{0,1,2}.tar.gz ) and the script cycles between them and flashes the LED to show which one its loading. My goal was to load the first configuration (Universal Repeater) use luci to connect to hotel wifi, then click reset button to reboot and activate OpenVPN+Repeater configuration. I added the third configuration when I realized I also wanted it to act as an AP to my LTE modem.

OpenWRT is great and super configurable but I prefer simple web interfaces - the Gl.iNet one is nice, and much easier than luci , especially on my phone, but it doesn’t have the functions I need. If there was a ‘Universal Repeater’ wizard with an option to activate OpenVPN and route all traffic over the tunnel I think I would just use that.

Great idea about resetting wireless/network and avoiding reboot. I’ll give that a try this weekend.

Thanks

Craig

 

  1. Yes, the config name will be reserved

It is very useful to add the things you mentioned, which is also required by RangerZ and some other users. But it is not easy. When adding more things, the UI will be getting more complicated, making it not easy to use.

I am thinking how to do this. I need someone working on the UI and usability.

I figured out how to activate the leds on radio1 using luci > System > LED Configuration.

I’m now writing a script to compare current configuration with a backup and output the uci commands to switch configurations. That way I can be more selective if I want to retain certain configurations.

What is the uci command to add a wifi-device with a name?
i.e.
config wifi-device ‘radio1’

“uci add wireless wifi-device” would create the section without the ‘radio1’ at the end.

Thanks

Craig

 

Don’t use uci add, use

uci set wireless.radio1=‘wifi-device’

Aha! That works. Still trying to figure out uci.

I’ve attached my cfg_diff.pl script if anyone is interested.

A few more discoveries…

  • The right way to backup/restore on the device is to use sysupgrade i.e. sysupgrade --create-backup /root/file.tgz sysupgrade --restore-backup /root/file.tgz
  • Its easy to add web-accessible insecure non-luci cgi-bin scripts. Just create files in /www/cgi-bin directory. I now have a basic web interface to create and manage multiple config backups.

Yes, you can just use shell script/lua to write cgi, insecure.