1

I'm using my Pi as a WAP (wireless access point). Is it possible to have two separate WiFi networks coming from the same Pi? I bought a usb adaptor that supports 8 APs, but I can only get one wap showing and working.

I'm using a Raspberry pi 4 and using command iw list the adaptor shows up correctly. I have modified the dhcpcd.conf file to include both interfaces wlan0 and wlan1, the dnsmasq.conf file to indicate the range of ip addresses and two separate hostapd.conf files for two networks. In /etc/default/hostapd I also indicated both the paths for hostapd.conf.

Still only one wlan shows up in ifconfig, any idea why? I really appreciate any help.

5
  • If you have 2 USB WiFi sticks, I would bet it works. Is this an option, or are you intending to use only one stick? Which Pi version do you have?
    – Marcel
    Commented Jul 10, 2019 at 19:41
  • Hi Marcel, thank you for replying. I'm using raspberry pi 4 and thinking to get another wifi adaptor so I can have two wifi running.
    – Yiming Xie
    Commented Jul 10, 2019 at 19:51
  • Have a look into this: thepi.io/…. You will have wlan0 and wlan1. I guess you will fail at step 5, because the config would allow only 1 interface.
    – Marcel
    Commented Jul 10, 2019 at 19:56
  • Hi Marcel, thanks for your reply. I have used this tutorial to set up my first WAP, adding a second one should be more or less the same right?
    – Yiming Xie
    Commented Jul 10, 2019 at 21:57
  • Hi Ingo, thank you for your help! I'll look into wifi direct too.
    – Yiming Xie
    Commented Jul 10, 2019 at 22:01

2 Answers 2

1

The wifi device on a Raspberry Pi can only make one access point at a time. To have a second access point you have to use an additional USB/wifi dongle that also supports an access point.

How to setup a single access point you can look at Setting up a Raspberry Pi as an access point - the easy way, section Setting up a stand alone access point. This is using interface wlan0. you can just repeat the same setup by replacing everywhere wlan0 with wlan1. Then you have two independent services that you can manage each separately, for example start and stop them:

rpi ~$ sudo systemctl stop [email protected]
rpi ~$ sudo systemctl start [email protected]

There are other combinations possible, maybe with the eth0 as uplink to an internet router or bridged with one access point.

5
  • Hi Ingo, many thanks to your reply! My wifi dongle is on the way and I'll let you know how it is going.
    – Yiming Xie
    Commented Jul 11, 2019 at 13:13
  • Hi @YimingXie, have you verified that he wifi dongle supports an access point?
    – Ingo
    Commented Jul 11, 2019 at 15:01
  • Hi @Ingo, yes it's the usb adaptor from the pihut, and running the command "iw list" gives me '#{AP, mesh point} <= 8'. I've tried to set up the second wifi followinglink for consistency (I used it to set up the first wifi hotspot) but it turns out that both wlan0 and wlan1 appears in ifconfig but both of them are "Not associated". I have separate hostapd files for both wlans. If you have any idea why this happens please let me know. Thank you so much!
    – Yiming Xie
    Commented Jul 15, 2019 at 11:08
  • @YimingXie Sorry, but I don't invest into old stuff networking anymore. I'm looking forward to systemd-networkd.
    – Ingo
    Commented Jul 15, 2019 at 14:46
  • Hi @Ingo, still thanks for all the help! Have a great day!
    – Yiming Xie
    Commented Jul 15, 2019 at 15:13
0

Actually hostapd is capable of setting up multiple access points on the same wifi interface and the same frequency (and even using multiple vlans to have actually separated networks) in case the wifi hardware has support for multiple APs.

The hostapd configuration can be quite complicated especially since the documentation is misleading in many places... Also due to the configuration having to match the hardware, you are often left with trial and error.

What you need a second wifi dongle for, is when you want to create an AP on another frequency. E.g. you need one dongle for a (multitude of) 2.5G networks and another dongle for a (multitude of) 5G networks.

Example configuration, credits to sensepost

The following is a shameless copy of https://github.com/sensepost/hostapd-mana/wiki/Multiple-Networks

Different networks can be created in the hostapd config with the bss keyword. For example, if we take the simplest hostapd.conf as our starting example:

ssid=hostapd-mana wifi
channel=6
hw_mode=g

We can add another network with:

ssid=second wifi

However, hostapd will create the second interface as a +1 offset of the original interface’s MAC address. This regularly causes problems for me, and I find hardcoding the original interface’s MAC address to something ending in :00 fixes it. Thus, the complete simplest config for two networks would be:

bssid=aa:bb:cc:dd:ee:00
ssid=hostapd-mana wifi
channel=6
hw_mode=g
bss=wlan0_0
ssid=second wifi

Depending on your adapter, it’s often possible to create more networks, for example, to add a third network:

ssid=third wifi

Multiple Security Configs

Additionally, the security options for each network can be varied. For example, to create an open, WPA/2 PSK and WPA/2 EAP network at the same time, using the options discussed in Creating PSK or EAP Networks:

bssid=aa:bb:cc:dd:ee:00
ssid=OpenNet
channel=6
hw_mode=g

bss=wlan0_0
ssid=PSKNet
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_passphrase=ASecurePassword
auth_algs=3

bss=wlan0_1
ssid=EAPNet
wpa=3
wpa_key_mgmt=WPA-EAP
wpa_pairwise=TKIP CCMP
auth_algs=3
ieee8021x=1
eapol_key_index_workaround=0
eap_server=1
eap_user_file=hostapd.eap_user
ca_cert=ca.pem
server_cert=server.pem
private_key=server.key
private_key_passwd=password
dh_file=dhparam.pem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.