fjugaldev
Posts: 12
Joined: Sun Jul 23, 2017 3:02 pm

How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sat Jul 29, 2017 4:59 pm

Hi everybody!

I want to configure my raspberry in the following way:
https://goo.gl/cQhhQq

What i need and i´m tired of trying a lot of configurations without success results is

I have a rpi with 2 wifi dongles connected and a ethernet connection to the router. I need to configure the rpi to:

1. Configure eth0 (with ip: 192.168.1.2) to get internet access from router (192.168.1.1).
2. use wifi connection from wlan0 (with ip: 192.168.1.3) with internet access too.
3. Use wlan1 (with ip: 192.168.2.1) as Access Point but without internet access (Only lan access to web server).

It's this possible?.

What i made was:

1. eth0 has connection to router and with internet access.
2. I configured wlan0 as a bridge with eth0 and with internet access.

When i test this it works, my rpi has internet access via eth0 and my wifi wlan0 is showing his ssid correctly and i can get connected and with internet access.

The thing is when i try to put wlan1 as Access Point i don´t know how to configure wlan0 and wlan1 together. When i try, wlan1 is the only visible wifi ssid (but don´t let me get connected to this wifi) of my network and wlan0 doesn´t show up.

This is my /etc/network/interfaces file configuration:

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

# Connection to Internet
auto wlan0
iface wlan0 inet dhcp
    hostapd /etc/hostapd/hostapd-wlan0.conf

# Access Point
auto wlan1
iface wlan1 inet dhcp
    hostapd /etc/hostapd/hostapd-wlan1.conf

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
And this is my hostapd-wlan0.conf

Code: Select all

interface=wlan0
driver=nl80211
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
# This part is about setting SSID and WPA2 password
ssid=SSID-1
wpa_passphrase=password1
# This line ask hostapd to add wlan0 to the bridge br0
bridge=br0
And this is my hostapd-wlan1.conf

Code: Select all

interface=wlan1
driver=nl80211
hw_mode=g
channel=7
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
# This part is about setting SSID and WPA2 password
ssid=SSID-2
wpa_passphrase=password2
Another thing that i really want is

1. eth0 will be in the network 192.168.1.* with ip: 192.168.1.2
2. wlan0 will be too in the network 192.168.1.* with ip: 192.168.1.3
3. I want to put wlan1 in the network 192.168.2 with ip: 192.168.2.1.* It´s this possible setting wlan1 as static in interfaces configuration? with this i'll be able to make a request on the local web server in the network 192.168.1.*?

I don´t know if i missing some configuration but i need your help to make this possible xD

cheers!

Francisco.

epoch1970
Posts: 3711
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sat Jul 29, 2017 8:35 pm

The case for wlan1 is easy. Give it the address you want and start hostapd on it. Then you'll want a dhcp server listening on wlan1 I suppose.

With eth0 and wlan0, what I would do is add them both to a bridge, with address 192.168.1.2.
In a bridge, interfaces have no IP address. A bridge is an IP layer 2 devices, it only knows MAC addresses.
A bridge is like a physical switch. If you don't give an address to your bridge, it looks like a "dumb" switch. If you give it an address, eg 192.168.1.2 then it looks like a "smart" switch with its configuration web GUI.

You need this, roughly:
- In /etc/dhcpcd.conf, block dhcpcd from interfering with your config in /etc/network/interfaces:

Code: Select all

denyinterfaces eth0 wlan0 wlan1 br0
- In /etc/network/interfaces:

Code: Select all

auto wlan0
iface wlan0 inet manual

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge-ports eth0 
# wlan0 added later by hostapd
- In /etc/hostapd/hostapd.conf:

Code: Select all

interface=wlan0
bridge=br0
It would seem natural to add wlan0 to the bridge in the interfaces file. But at that moment the wifi interface is in its default client mode, and the wifi standard says a wifi interface in client mode cannot belong to a bridge. Hostapd first sets it to AP mode then adds it to the bridge, so it's ok then.
(If you prefer, you can still write "bridge-ports eth0 wlan0", bridging wlan0 will just harmlessly fail and hostapd will finish the job.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fjugaldev
Posts: 12
Joined: Sun Jul 23, 2017 3:02 pm

Re: How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sat Jul 29, 2017 9:42 pm

Hi epoch1970,

Thank´s for your answer.

Ok, i had configured everything with eth0 and wlan0 as you mentioned. With the wlan1 i had edited my interfaces config and set to static with a custom address just like i wanted.

I noticed that even when i made changes on my configuration and rebooted the rpi, the problem still there, so i decided to unplug the usb dongle for wlan1, comment out wlan1 config on my interfaces file and reboot the rpi again and now work´s with wlan0.. i can see the SSID on my wireless list and i can connect with internet connection.

When i plug again the usb dongle of wlan1 with no configuration changes, just plugged and reboot rpi, the problem appears again so i think that the problem is between the usb dongles. The usb dongles are both of brand TENDA but one is model U1 and the other model W300U. Does this have to do with the problem?, it´s possible that i´m missing some hardware configuration?

Cheers! :D

Francisco

epoch1970
Posts: 3711
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sun Jul 30, 2017 8:06 am

fjugaldev wrote:
Sat Jul 29, 2017 9:42 pm
When i plug again the usb dongle of wlan1 with no configuration changes, just plugged and reboot rpi, the problem appears again so i think that the problem is between the usb dongles.
Mhh.
If plugging wlan1 and rebooting gives you a working AP on 192.168.2.x and a working wired access to the Internet, then the network setup is ok. If plugging wlan0 alone and rebooting gives you an AP with wireless access to the Internet, then wifi adapters are working.

If things break when plugging both USB wifi devices, I would look into a power issue, but your hostapd.conf could also be reworked:
- AFAIK HT-40 should be either HT-40+ or HT-40-, and preferably it should not be there at all because this directs the use of 40MHz width channels in the 2.4GHz band. This setting is not neighbour-friendly at all, and I don't think all devices support it. I would try without the ht-capab option.
- Wifi channels numbers represent the center of a frequency band. Using channel 6 and 7 is certain to create competition between the 2 APs. This wiki page might be of use.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fjugaldev
Posts: 12
Joined: Sun Jul 23, 2017 3:02 pm

Re: How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sun Jul 30, 2017 3:18 pm

Hi epoch1970,

It's work's dude! hahaha, for the wlan0 i set the ht_capab to ht_capab=[HT40+][SHORT-GI-40] but i had to disable it for the wlan1 so i think that both usb dongles will not work with the ht_capab so i decided to set it only for the wlan0 because will be sharing a internet access so i want to optimize the speed for this wifi device.

So i just have one last question. wlan0 is 300Mbps capable and wlan1 is 150Mpbs, this according to what it says on the product description, so i just wanna to know if exist any way to configure each usb dongle to get the maximun speed. I think that with the ht_capab will be possible but i don't know how to make it work together with that configuration.

But at the moment i can go ahead with my project and take some time later to think about this point but if you knows how can i do to solve this last issue i will appreciate your help xD

Cheers! :D

Francisco

epoch1970
Posts: 3711
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to configure Raspberry PI 3 with 2 USB Wifi dongles

Sun Jul 30, 2017 9:37 pm

I don't know the details but you are going to be severely limited by the single USB channel upstream on the Pi.
The built-in wifi interface doesn't use USB AFAIK, but don't expect to turn a Pi into a serious switch or router. With ethernet it is kind of slow, with wifi even more so.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”