jeclark2006
Posts: 9
Joined: Wed Aug 09, 2017 6:45 pm

PI Zero W, has it both AP and Client connections?

Mon Aug 21, 2017 6:19 am

The Zero W supports WIFI and I thought briefly I had both AP and Client connections. But for some reason, I only see the interface in managed mode even though an invocation of 'hostapd' is running, and looks to have setup with 'wlan0' as its interface.

Is it possible to use both modes on the Zero W WIFI interface?

And if so, what are the config steps.

Thanks,
John Clark.

User avatar
DougieLawson
Posts: 35805
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: PI Zero W, has it both AP and Client connections?

Mon Aug 21, 2017 2:16 pm

Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
B.Goode
Posts: 8256
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: PI Zero W, has it both AP and Client connections?

Mon Aug 21, 2017 2:21 pm

Is it possible to use both modes on the Zero W WIFI interface?
It is certainly possible to use either.

But do you mean you want client and AP modes active concurrently?

jeclark2006
Posts: 9
Joined: Wed Aug 09, 2017 6:45 pm

Re: PI Zero W, has it both AP and Client connections?

Tue Aug 22, 2017 7:48 pm

This describes how to setup the AP mode.

What I'm asking about is if anyone has setup for dual Client and AP mode. How this is done is using a second 'virtual' interface. One associated with client connectivity and one for the AP functionality.

I'm familiar with Atheros 802.11 devices, but that's not what is on the Zero W.

I do have things such that there is a wlan0 and a uap0 device. But from the log file there's a series of error messages, shown below.

Aug 20 19:17:16 das-boot dhcpcd[376]: uap0: IAID eb:4f:6c:be
Aug 20 19:17:16 das-boot dhcpcd[376]: uap0: IAID conflicts with one assigned to wlan0
Aug 20 19:17:16 das-boot dhcpcd[376]: uap0: carrier lost

I've tried manually setting the hw ethernet addresses of the two interfaces to be different, but that seems to be ignored.

Thanks,
John Clark.

vivianliu
Posts: 1
Joined: Wed Aug 30, 2017 2:59 am

Re: PI Zero W, has it both AP and Client connections?

Wed Aug 30, 2017 3:22 am

:mrgreen:
I can definitely help you on this by amending a few of files.

Create or edit your wpa_supplicant configuration:

Code: Select all

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
        ssid="YOUR_WIFI"
        psk="wifi_password"
        key_mgmt=WPA-PSK
}
Edit the interfaces configuration:

Code: Select all

sudo vi /etc/network/interfaces

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
auto wlan0
auto wlan1

iface lo inet loopback

allow-hotplug wlan0

iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan1 inet static
        address 192.168.10.1
        netmask 255.255.255.0
        network 192.168.10.0
        broadcast 192.168.10.255
        gateway 192.168.10.1
Install hostapd and dnsmasq:

Code: Select all

sudo apt-get install hostapd dnsmasq
Create a new hostapd configuration:

Code: Select all

sudo vi /etc/hostapd/hostapd.conf
The new configuration should look like this, change your wifi ssid and password as your wish:

Code: Select all

interface=wlan1
ssid=Pi0W
hw_mode=g
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=new_password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Modify the hostapd default configuration to use your new configuration file:

Code: Select all

sudo vi /etc/default/hostapd
Add the following line:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
Modify the dnsmasq configuration:

Code: Select all

sudo vi /etc/dnsmasq.conf

Code: Select all

interface=lo,wlan1
no-dhcp-interface=lo,wlan0
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.10.100,192.168.10.150,12h
Modify sysctl.conf:

Code: Select all

sudo vi /etc/sysctl.conf
Uncomment the next line to enable packet forwarding for IPv4:

Code: Select all

net.ipv4.ip_forward=1
Modify the rc.local script to run some commands on boot up.

Code: Select all

sudo vi /etc/rc.local
Add the following line before "exit 0".

Code: Select all

service dnsmasq start
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 ! -d 192.168.10.0/24 -j MASQUERADE
ifdown wlan0
ifup wlan0
Last step, reboot your Pi Zero W:

Code: Select all

sudo reboot
Enjoy your new AP designed by Rasyberry Pi :D

shanem2
Posts: 13
Joined: Tue Jan 23, 2018 10:38 am

Re: PI Zero W, has it both AP and Client connections?

Wed Jul 04, 2018 3:52 am

@vivianliu,

I'm going through your config and comparing against one that I've been trying to get to work; viewtopic.php?f=36&t=138730&start=150 (post by @SurferTim on Fri Jun 22, 2018 3:56 am.

Your config references a wlan1 and wlan0. Where does wlan1 come from or get defined?

The only difference is you define wlan1 in the "/etc/network/interfaces" file, where the other configuration applies it in the "/etc/rc.local" file using the command 'iw dev wlan0 interface add uap0 type __ap'.

Any assistance on getting both AP and Client working on a RPi 3B+ would be appreciated.

Return to “Beginners”