TorBox icon indicating copy to clipboard operation
TorBox copied to clipboard

changing hostapd wlan address

Open anvarit opened this issue 3 years ago • 5 comments

I'm using the torbox on a rpi 4. After installing everything works but the torbox uses the internal RPi WLAN adapter (wlan0)

When I try to modify the hostapd.conf file the change the adapter settings to wlan1 (Atheros AR9271) and reboot the rpi the setting is reverted back to wlan0

The internet connection is configured to ethernet and I just want to use the torbox as an access point but with the more powerfull AR9271

anvarit avatar Oct 15 '21 19:10 anvarit

If the AP is activated and someone is using main menu entry 7, TorBox will switch back to the AP set to wlan 0 as the interface for the AP. This is to avoid locking themself out when pulling the USB wifi adapter or when the adapter is not working correctly.

To disable this fallback method, you have to change the /etc/rc.local. There you have to remove the following lines:

if grep "iface wlan1 inet static" /etc/network/interfaces || grep "^interface=wlan1" /etc/hostapd/hostapd.conf ; then
  sudo ifdown wlan0
  sudo ifdown wlan1
  sudo sed -i "s/^auto wlan0/auto wlan1/" /etc/network/interfaces
  sudo sed -i "s/^iface wlan0 inet dhcp/iface wlan1 inet dhcp/" /etc/network/interfaces
  sudo sed -i "s/^iface wlan1 inet static/iface wlan0 inet static/" /etc/network/interfaces
  sudo sed -i "s/^interface=wlan1/interface=wlan0/" /etc/hostapd/hostapd.conf
  sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan1/" /home/torbox/torbox/run/torbox.run
  sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" /home/torbox/torbox/run/torbox.run
  sudo ifup wlan0 &>/dev/null &
  sudo ifup wlan1 &>/dev/null &
  sudo systemctl restart hostapd
  sudo systemctl restart isc-dhcp-server
  sleep 5
fi

if ip link | grep wlan1 | grep "state DOWN" ; then
  sudo /usr/bin/python3 /home/torbox/torbox/torbox_wireless_manager.py -i wlan1 -a
  sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan1/" /home/torbox/torbox/run/torbox.run
  sleep 5
fi

I could check if I can add something to the next TorBox version to change or deactivate the fallback method. Could you tell me from which interface you get Internet?

radio24 avatar Oct 16 '21 21:10 radio24

Understable to have a stable image that allows for tinkering and having a fallback method Internet here is eth0. (POE hat) My thoughts is that having an options that allows you to choose the wlan adapter would be the ideal solution. Ofcourse this can also bring new problems if you change wireless nics because they will become wlan2, 3 and so on.

Now for me this isn't an issue, I reversed my setup. Used the wlan1 as internet input and put the eth0 in to a vlan and added a new SSID in my wireless infrastructure with that vlan. This solved my isse and gives me coverage all over the house. The wlan0 still broadcasts the Torbox ssid as mangement interface to the torbox.

anvarit avatar Oct 17 '21 09:10 anvarit

Thanks for the additional information. The goal is to keep it as straightforward as possible so that people with no technical skills can use TorBox. I'm thinking about giving more flexibility for experts in a separate sub-menu in one of the upcoming versions (however, the current priority is to include the support for onion services). My idea is to let the main menu unchanged, but then in this expert sub-menu, the user can change the adapter for the AP. I will put it on my to-do list.

radio24 avatar Oct 17 '21 09:10 radio24

Would be great, thanks for the great work that you already did!

anvarit avatar Oct 17 '21 09:10 anvarit

I will keep the issue as a reminder for me to follow up.

radio24 avatar Oct 17 '21 10:10 radio24

In TorBox v.0.5.3 in the Danger Zone submenu the failback which resets the AP to wlan0 during the boot can be disabled. --> Issue closed

radio24 avatar Jul 11 '23 20:07 radio24