Jump to content
  • 0

Orange pi zero, wifi: ap+managed


asp
 Share

Question

Hello!

 

I tried to configure built-in wifi module to work as two wifi interfaces at the same time. I had already configured hostapd+dhcpd at the first interface, at the second interface (...iw add interface...) I could scan my home wifi network (wpa2), but I couldn't connect to it (wrong key). I used utilities to connect like wpa_cli, wpa_supplicant, iwconfig, iw. Did anybody done that, I mean is it possible? What i'm doing wrong?

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0

If you are using wpa_supplicant for the wpa2-type,  keymode is actually just wpa. (wpa2 just gives the authentication error).

I am evaluating Orange Pi devices for a WIFI AP - nodehub to be used with ESP8266 - devices so I have tinkered between Zero, PC+ and Plus 2E H3

 

 

Hello!
 
I tried to configure built-in wifi module to work as two wifi interfaces at the same time. I had already configured hostapd+dhcpd at the first interface, at the second interface (...iw add interface...) I could scan my home wifi network (wpa2), but I couldn't connect to it (wrong key). I used utilities to connect like wpa_cli, wpa_supplicant, iwconfig, iw. Did anybody done that, I mean is it possible? What i'm doing wrong?

 

Link to comment
Share on other sites

Search Before Posting!

  • 0

If you are using wpa_supplicant for the wpa2-type,  keymode is actually just wpa. (wpa2 just gives the authentication error).

I am evaluating Orange Pi devices for a WIFI AP - nodehub to be used with ESP8266 - devices so I have tinkered between Zero, PC+ and Plus 2E H3

 
Thank you for your response.
I want to use OPi zero for mqtt+openhab2+wifi_ap_mode for esp8266+same_wifi as client to connect to the internet.
If i want to connect to AP which uses WPA2, how i need to configure my connection? What I need use instead wpa_supplicant ?
 
2. After reboot, OPi zero missing second virtual wifi interface, how to save it?
Link to comment
Share on other sites

  • 0

 

 
Thank you for your response.
I want to use OPi zero for mqtt+openhab2+wifi_ap_mode for esp8266+same_wifi as client to connect to the internet.
If i want to connect to AP which uses WPA2, how i need to configure my connection? What I need use instead wpa_supplicant ?
 
2. After reboot, OPi zero missing second virtual wifi interface, how to save it?

 

 

We don't plan to use Wireless client to connect to the actual outside world, just hostap for the esp8266 to do the RESTAPI posting.

How did you create the client / ap separation ? I think basically no matter which you use wpa_supplicant or network manager, you use the interace-name to bind the saved information.

/etc/NetworkManager/system-connections for the nmcli and example /etc/wpa_supplicant/ for wpa_supplicant - scripts.

I think you can also use nmcli or wpa_cli to do them all manually from a startup service if required.

Link to comment
Share on other sites

  • 0

We don't plan to use Wireless client to connect to the actual outside world, just hostap for the esp8266 to do the RESTAPI posting.

How did you create the client / ap separation ? I think basically no matter which you use wpa_supplicant or network manager, you use the interace-name to bind the saved information.

/etc/NetworkManager/system-connections for the nmcli and example /etc/wpa_supplicant/ for wpa_supplicant - scripts.

I think you can also use nmcli or wpa_cli to do them all manually from a startup service if required.

 

At first i deleted wifi interface using utility iw. Then I create two interfaces:
 iw phy phy1 interface add wlan0 type __ap
 iw phy phy1 interface add wlan1 type managed
 
First interface for hostapd - working good.
Second interface for connection my Opi Zero to internet.
 
Question is why my second interface didn't want to connect to internet(gome wifi AP), i got always wrong key. home wifi AP working using WPA2. I want to ask, may be someone done the same already.
Link to comment
Share on other sites

  • 0

I have to try it when have time.

If you are using network manager you should create two connection profiles (one client dhcp and one ap static ip) ?

If not then create the virtual interfaces to the /etc/network/interfaces file and use wpa_supplication for the client connection
(i am not familiar how this is done, only knowledge of bridges on openstack)

 

However as you are also using the eth0 lan connection it may lead into a "arp flux" - scenario if the lan connection and wireless client share the same subnet ?

 

 

At first i deleted wifi interface using utility iw. Then I create two interfaces:
 iw phy phy1 interface add wlan0 type __ap
 iw phy phy1 interface add wlan1 type managed
 
First interface for hostapd - working good.
Second interface for connection my Opi Zero to internet.
 
Question is why my second interface didn't want to connect to internet(gome wifi AP), i got always wrong key. home wifi AP working using WPA2. I want to ask, may be someone done the same already.

 

Link to comment
Share on other sites

  • 0

I have to try it when have time.

If you are using network manager you should create two connection profiles (one client dhcp and one ap static ip) ?

If not then create the virtual interfaces to the /etc/network/interfaces file and use wpa_supplication for the client connection

(i am not familiar how this is done, only knowledge of bridges on openstack)

 

However as you are also using the eth0 lan connection it may lead into a "arp flux" - scenario if the lan connection and wireless client share the same subnet ?

 

It will be great if you try to done this too.
Yes, network manager and spa_supplication are on.
I note, that if I want to start wifi as AP (hostapd) mode or client mode (wpa_cli utility) on wlan0 - it works. "arp flux" - may be, but it's not a problem, because i can see connection to home_wifi, wifi link is up. The same operations on second wifi interface didn't work (don't matter, ap or client mode).

 

This is some information:

 

Orange PI zero , armbian 5.24 (latest)

 

wpa_cli:

 

Selected interface 'wlan1'

Interactive mode

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

> add_network

0

> set_network 0 ssid "Rocks"

OK

<3>CTRL-EVENT-SCAN-STARTED 1

<3>CTRL-EVENT-SCAN-RESULTS 

<3>WPS-AP-AVAILABLE-AUTH 

> set_network 0 psk "********"

OK

> enable_network 0

OK

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="Rocks" auth_failures=1 duration=10 reason=CONN_FAILED

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SCAN-STARTED

<3>Reject scan trigger since one is already pending

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="Rocks"

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="Rocks" auth_failures=2 duration=23 reason=CONN_FAILED

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SCAN-STARTED

<3>CTRL-EVENT-SCAN-RESULTS

<3>WPS-AP-AVAILABLE-AUTH

<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="Rocks"

<3>SME: Trying to authenticate with e4:8d:8c:e0:de:db (SSID='Rocks' freq=2412 MHz)

<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="Rocks" auth_failures=3 duration=46 reason=CONN_FAILED

 

 

iwconfig:

wlan1 IEEE 802.11bgn ESSID:off/any

Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm

Retry long limit:7 RTS thr:off Fragment thr:off

Encryption key:off

Power Management:on

wlan0 IEEE 802.11bgn Mode:Master Frequency:2.412 GHz Tx-Power=20 dBm

Retry long limit:7 RTS thr:off Fragment thr:off

Power Management:on

 

iw list:

 

Wiphy phy1

Band 1:

Capabilities: 0x110

HT20

Static SM Power Save

RX Greenfield

RX STBC 1-stream

Max AMSDU length: 3839 bytes

No DSSS/CCK HT40

Maximum RX AMPDU length 32767 bytes (exponent: 0x002)

Minimum RX AMPDU time spacing: No restriction (0x00)

HT TX/RX MCS rate indexes supported: 0-7

Frequencies:

* 2412 MHz [1] (20.0 dBm)

* 2417 MHz [2] (20.0 dBm)

* 2422 MHz [3] (20.0 dBm)

* 2427 MHz [4] (20.0 dBm)

* 2432 MHz [5] (20.0 dBm)

* 2437 MHz [6] (20.0 dBm)

* 2442 MHz [7] (20.0 dBm)

* 2447 MHz [8] (20.0 dBm)

* 2452 MHz [9] (20.0 dBm)

* 2457 MHz [10] (20.0 dBm)

* 2462 MHz [11] (20.0 dBm)

* 2467 MHz [12] (20.0 dBm) (no IR)

* 2472 MHz [13] (20.0 dBm) (no IR)

* 2484 MHz [14] (20.0 dBm) (no IR)

Bitrates (non-HT):

* 1.0 Mbps

* 2.0 Mbps

* 5.5 Mbps

* 11.0 Mbps

* 6.0 Mbps

* 9.0 Mbps

* 12.0 Mbps

* 18.0 Mbps

* 24.0 Mbps

* 36.0 Mbps

* 48.0 Mbps

* 54.0 Mbps

max # scan SSIDs: 2

max scan IEs length: 2257 bytes

Retry short limit: 7

Retry long limit: 4

Coverage class: 0 (up to 0m)

Supported Ciphers:

* WEP40 (00-0f-ac:1)

* WEP104 (00-0f-ac:5)

* TKIP (00-0f-ac:2)

* CCMP (00-0f-ac:4)

Available Antennas: TX 0 RX 0

Supported interface modes:

* IBSS

* managed

* AP

* AP/VLAN

* monitor

* mesh point

* P2P-client

* P2P-GO

software interface modes (can always be added):

* AP/VLAN

* monitor

valid interface combinations:

* #{ managed } <= 2, #{ AP } <= 1,

total <= 3, #channels <= 1

* #{ managed } <= 3,

total <= 3, #channels <= 1

* #{ managed } <= 2, #{ P2P-client, P2P-GO } <= 1,

total <= 3, #channels <= 1

Supported commands:

* new_interface

* set_interface

* new_key

* start_ap

* new_station

* new_mpath

* set_mesh_config

* set_bss

* authenticate

* associate

* deauthenticate

* disassociate

* join_ibss

* join_mesh

* remain_on_channel

* set_tx_bitrate_mask

* frame

* frame_wait_cancel

* set_wiphy_netns

* set_channel

* set_wds_peer

* probe_client

* set_noack_map

* register_beacons

* connect

* disconnect

Supported TX frame types:

* IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0

Supported RX frame types:

* IBSS: 0xd0

* managed: 0x40 0xd0

* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0

* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0

* mesh point: 0xb0 0xc0 0xd0

* P2P-client: 0x40 0xd0

* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0

WoWLAN support:

* wake up on anything (device continues operating normally)

* wake up on disconnect

Device supports AP-side u-APSD.

HT Capability overrides:

* MCS: ff ff ff ff ff ff ff ff ff ff

* maximum A-MSDU length

* supported channel width

* short GI for 40 MHz

* max A-MPDU length exponent

* min MPDU start spacing

Device supports TX status socket option.

Device supports HT-IBSS.

 

Commands:

iw dev wlan0 del

74 iw phy phy1 interface add wlan0 type __ap

110 iw phy phy1 interface add wlan1 type managed

 

 

 

 

 

systemctl status hostapd.service

Б≈■hostapd.service - LSB: Advanced IEEE 802.11 management daemon

Loaded: loaded (/etc/init.d/hostapd)

Active: active (running) since Mon 2016-11-14 09:52:12 CET; 5min ago

Process: 845 ExecStop=/etc/init.d/hostapd stop (code=exited, status=0/SUCCESS)

Process: 852 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)

CGroup: /system.slice/hostapd.service

Б■■Б■─855 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd.conf

Nov 14 09:52:12 orangepizero hostapd[852]: Starting advanced IEEE 802.11 management: hostapd.

Nov 14 09:52:12 orangepizero systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.

 

 

systemctl status wpa_supplicant.service

Б≈■wpa_supplicant.service - WPA supplicant

Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; disabled)

Active: active (running) since Mon 2016-11-14 09:50:58 CET; 7min ago

Main PID: 681 (wpa_supplicant)

CGroup: /system.slice/wpa_supplicant.service

Б■■Б■─681 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

Link to comment
Share on other sites

  • 0

I'm also trying to setup ap+managed. Individually, I can have a station or ap and it works fine. When I have both interfaces, only one of them is functional. One thing to keep in mind is that both station and ap need to use the same channel, as I understand it.

Link to comment
Share on other sites

  • 0

I'm also trying to setup ap+managed. Individually, I can have a station or ap and it works fine. When I have both interfaces, only one of them is functional. One thing to keep in mind is that both station and ap need to use the same channel, as I understand it.

 

I already done it using nmtui utility, but it works only on Mainline 4.9.3 Ubuntu Xenial (nightly releases). Hostapd didn't tried.

 

So I conclude that something wrong with drivers in legacy 3.4.113

Link to comment
Share on other sites

  • 0

I think I am seeing the same issue in legacy 3.4.113.

I can get hostapd working with wlan0 in access point only mode. Other computers can see the SSID and connect to it.
I then try to configure wlan0 as two virtual interfaces:

sudo iw dev wlan0 del
sudo iw phy phy1 interface add wlan0_station type station
sudo iw phy phy1 interface add wlan0_ap type __ap

This all works fine. ifconfig and iwconfig both list the two new interfaces: wlan0_station and wlan0_ap.
I can edit /etc/network/interfaces and add entries for wlan0_station and wlan0_ap.
I can use ifup to bring up both interfaces.

  • wlan0_station connected to my home router and assigned an address via dhcp.
  • wlan0_ap assigned a static ip address.

I then start up hostapd with my hostapd.conf set to use wlan0_ap interface (interface=wlan0_ap) and the channel set to the same channel as used by my router (channel=11).

Hostapd starts up normally and reports that the access point is up.
But no other computers ever see the SSID of the access point and none can connect even if the SSID is manually entered.

I'm out of ideas, so I'm suspecting it's a driver issue. Naturally, I would be very interested to know if anyone has got this working or if there's anything obvious I've missed.
 

Link to comment
Share on other sites

  • 0

I already done it using nmtui utility, but it works only on Mainline 4.9.3 Ubuntu Xenial (nightly releases). Hostapd didn't tried.

 

So I conclude that something wrong with drivers in legacy 3.4.113

 

Do you mean that you have both AP and Station mode running simultaneously on two different network virtual interfaces by using 4.9.3?

Link to comment
Share on other sites

  • 0

I already done it using nmtui utility, but it works only on Mainline 4.9.3 Ubuntu Xenial (nightly releases). Hostapd didn't tried.

 

So I conclude that something wrong with drivers in legacy 3.4.113

 

I was able to run AP and Client modes simultaneously by switching to the 4.9.4 kernel! Thanks!

Link to comment
Share on other sites

  • 0

I was able to run AP and Client modes simultaneously by switching to the 4.9.4 kernel! Thanks!

 

What steps you did to switch kernel on debian?

 

2. Do you know how not to lose second virtual interface (wifi) after restart? I tried to create rules in udev, but it didn't help me (may be i wrote wrong rule)

Link to comment
Share on other sites

  • 0

2. Do you know how not to lose second virtual interface (wifi) after restart? I tried to create rules in udev, but it didn't help me (may be i wrote wrong rule)

 

I was playing around with this last night and the following worked for me...

 

I created an /etc/udev/rules.d/70-persistent-net.rules with the following contents:

 

SUBSYSTEM=="ieee80211", ACTION=="add|change", ATTR{macaddress}=="aa:bb:cc:dd:ee:xx", KERNEL=="phy1", \

RUN+="/sbin/iw dev wlan0 del", \

RUN+="/sbin/iw phy phy1 interface add wlan0_station type station", \

RUN+="/sbin/iw phy phy1 interface add wlan0_ap type __ap", \

RUN+="/bin/ip link set wlan0_ap address aa:bb:cc:dd:ee:yy"

 

Substitute aa:bb:cc:dd:ee:xx with your wlan0 mac address.

For aa:bb:cc:dd:ee:yy select a mac that will be unique on your network. I just took the wlan0 mac and incremented by 1.

 

After a reboot, ifconfig -a listed wlan0_station and wlan0_ap interfaces.

 

(My reference for this was this blog post: http://www.0xf8.org/2016/02/using-your-raspberry-pi-zeros-usb-wifi-adapter-as-both-wifi-client-and-access-point/)

Link to comment
Share on other sites

  • 0

Hello,

I am a new user of OPI Zero , I am trying also to create wifi AP .

I followed full of topic in different forum but, no success .

I there anybody whos get success on this device ? (and maybe can give a tutorial to help ... )

Thanks for help

Best regard

 

Using : Armbian_5.24_Orangepizero_Debian_jessie_default_3.4.113.7z

Link to comment
Share on other sites

  • 0

Hello,

Here is some news , and some hours to get this f...... wifi get working as i wish .

 

Bridge Eth0 to wlan0 , with dhcp and dns working

 

# nano /etc/default/hostapd

DAEMON_CONF="/etc/hostapd.conf"

 

# nano /etc/network/interfaces

 

# This file intentionally left blank
#
# All interfaces are handled by network-manager, use nmtui or nmcli on
# server/headless images or the "Network Manager" GUI on desktop images
auto lo br0
iface lo inet loopback
 
# wireless wlan0
allow-hotplug wlan0
iface wlan0 inet manual
 
# eth0 connected to the ISP router
allow-hotplug eth0
iface eth0 inet manual
 
# Setup bridge
iface br0 inet dhcp
    bridge_ports wlan0 eth0

# Lance le processus hostapd après l'initialisation des périphériques wlan0 et br0
  post-up /usr/sbin/hostapd -B /etc/hostapd.conf

 

# nano /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

[keyfile]
hostname=**YourHostName**

 

 

 

nano /etc/hostapd/hostapd.conf

# Nom du spot Wi-Fi
ssid=**YourSSID**
wpa_passphrase=**YourPassWord**
wpa=2
#wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP# interface wlan
du Wi-Fi
interface=wlan0
bridge=br0
# Wi-Fi ouvert, pas d'authentification ! =0 1
auth_algs=3
# nl80211 avec tous les drivers Linux mac80211
driver=nl80211# mode Wi-Fi
(a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g)
hw_mode=g
# canal de fréquence Wi-Fi (1-14)
channel=6
logger_stdout=-1
logger_stdout_level=2
# Maximum number of stations allowed in station table (255)
max_num_sta=5
# Beacon interval in kus (1.024 ms) =50
beacon_int=100
# DTIM (delivery trafic information message)
dtim_period=2
# RTS/CTS threshold; 2347 = disabled (default)
rts_threshold=2347
# Fragmentation threshold; 2346 = disabled (default)
fragm_threshold=2346
# code pay
country_code=FR
#disassoc_low_ack=1
ieee80211d=1
ieee80211n=1
#ht_capab=[HT40+][sHORT-GI-40][RX-STBC1][DSSS_CCK-40][MAX-AMSDU-3839]
require_ht=0
wmm_enabled=1
utf8_ssid=1

## Accept all MAC address ###
macaddr_acl=0

 

 

 

# nano /etc/sysctl.conf

net.ipv4.ip_forward = 1
sudo sysctl -p /etc/sysctl.conf

 

 

Remember to install all package with :
apt-get --reinstall install xxxxx

 

 

Help Sources :

https://www.cyberciti.biz/faq/debian-ubuntu-linux-setting-wireless-access-point/

http://antoine-schellenberger.com/linux/2014/12/14/tips_hostapd_bridge.html

 

If can help , i will edit on demand.

Link to comment
Share on other sites

  • 0
On 1/31/2017 at 1:14 AM, asp said:

 

What steps you did to switch kernel on debian?

 

2. Do you know how not to lose second virtual interface (wifi) after restart? I tried to create rules in udev, but it didn't help me (may be i wrote wrong rule)

I downloaded a new image from here: https://www.armbian.com/orange-pi-zero/#nightly

 

If you want to delete a virtual network interface you can write a script that will be executed on boot. Since I used nmcli to create the interfaces I would use that to delete them as well.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...