OpenWrt 的世界︰樹莓派 3B 【路由器】 WiFi 《A》

不知是否因為樹莓派 3B 內建 WiFi 有電源管理問題,或是由於沒有 monitor mode 不能跑 horst 頻譜分析。所以飛行派 BOM 裡有 WiFi  AP dongle 這一項?既然將選用 WiFi USB dongle 來作 Access Point ,當然最好是具有 IEEE802.11  相容模式。如是安裝 hostapd 也比較容易,無須顧慮驅動程式 device driver 的問題!

hostapd: IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator

hostapd is a user space daemon for access point and authentication servers. It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server. The current version supports Linux (Host AP, madwifi, mac80211-based drivers) and FreeBSD (net80211).

hostapd is designed to be a “daemon” program that runs in the background and acts as the backend component controlling authentication. hostapd supports separate frontend programs and an example text-based frontend, hostapd_cli, is included with hostapd.

Supported WPA/IEEE 802.11i/EAP/IEEE 802.1X features

  • WPA-PSK (“WPA-Personal”)
  • WPA with EAP (with integrated EAP server or an external RADIUS backend authentication server) (“WPA-Enterprise”)
  • key management for CCMP, TKIP, WEP104, WEP40
  • WPA and full IEEE 802.11i/RSN/WPA2
  • RSN: PMKSA caching, pre-authentication
  • IEEE 802.11r
  • IEEE 802.11w
  • RADIUS accounting
  • RADIUS authentication server with EAP
  • Wi-Fi Protected Setup (WPS)

─── 《飛行派工作日誌《四》

 

『專業』來自於『經驗』之積累,既然 OpenWrt 

 

文本有字,就不是『天書』也!

比方說,其中一個章節

Configure A(ccess) P(oint or ‘hotspot’) + STA(tion or ‘client’)

AP+STA mode allows OpenWrt to connect to a wireless hotspot (AP) and provide wireless access from that hotspot to anything connected to the OpenWrt AP and Ethernet ports, the ‘br-lan’ device. This assumes that your OpenWrt device has the default settings where the AP and Ethernet port are bridged.

Manual configuration

The changes below assume an OpenWrt default configuration, the relevant files are:

………

 

樹莓派論壇曾經討論︰

Pi 3 as wiireless client and wireless AP?

Sat Mar 05, 2016 4:18 am

Hi,
I just ordered my Pi 3 and am looking forward to its arrival. This will be my first one
I read a write up here:
http://makezine.com/2016/02/28/eben-upt … erry-pi-3/
Where the following comment is made:
“It seems likely, given the chipset, that the Raspberry Pi should be able to operate in both Access Point mode and client mode simultaneously. In other words, it can get its internet connection by joining on a wireless network, while simultaneously providing a second network as an access point to a ‘cloud’ of sensors. Both firewalling the sensor network away from the network that has laptops and games consoles, and humans, and extending the reach of the original network to inaccessible places.”That sounds like what I am looking for. I would like to run a webserver on the pi hosting a small site. I would like the pi would be connected to the internet via wifi connection, simultaneously I would to like connect to the pi locally with a phone or pc over wifi. While connected to the pi from the phone I would like to be able to request mysite.pi and it be served from the websever running on the pi and also be able to request google.com and have that be served from the internet.Is something like this possible?
What might the /etc/network/interfaces look like?
I assume I will end up with a configuration similar to this tutorial https://learn.adafruit.com/downloads/pd … -point.pdf
but it is using Ethernet to connect to the internet and broadcasting as an access point over wifi. I would like to do everything over wifi only.
What is the best way in network terms to describe what I am trying to achieve? I am not a network engineer.Thanks in advance.

……

Re: Pi 3 as wiireless client and wireless AP?

Tue Mar 22, 2016 12:49 am

I’m extremely new here (as can be seen by this post’s #) and fairly new to raspberry pi (like 2-3 months) but I’ve lurked here the whole time.

Just got in the new 3 and am enjoying it. Through this forum and a few others I’m close to getting sta+client going.

Setting up hostapd mostly normally (but change wlan0 to wlan1; change the channel to whatever iwlist shows for wlan0) and then setting up interfaces with wlan1 having whatever default gateway you want for the router then

sudo iw dev wlan0 interface add wlan1 type __ap

and then

 sudo hostapd /etc/hostapd/hostapd.conf

starts showing your new network available while still being able to use the client side on wlan0(what I’m communicating with it with to start with.

As I get it cleaned up, I’ll start making better step by steps. I just knew that with a little nudge, people with much more *nix skill will have it done in minutes vs. my hours or days.

Thank y’all for a great forum.
Robbie

 

答案是

行歸行,有依賴矣?

因為 #channels <=1 哩☻

root@LEDE:~# iw list
...
	valid interface combinations:
		 * #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
		   total <= 3, #channels <= 2
		 * #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
		   total <= 4, #channels <= 1

 

當然有人曾解釋呦☺

Deciphering the output of iw list valid interface combinations

I struggled with the same thing not so long ago. Took a bit of source code reading to find out the basics.

Yes, your adapter supports each of the modes listed.

Every line under valid interface combinations contains one possibilty for a combination. If there are several lines, you choose any line, and make a valid combination with the restrictions in this line. Each of the restrictions mentioned must be full filled.

Your adapter only has a single line, so there’s no choice.

The notation #{ ... } reads “number of interface of the following type”.

So in words, the line

#{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1, total <= 3, #channels <= 2

reads:

You can have a maximum a 3 simultaneous interfaces (in addition to the software interface modes). Those interfaces can use at most 2 different channels (so at least 2 interfaces must use the same channel).

You can have one managed interface (also called “station” or “client”), either one access point (AP) or one P2P-client or one P2P-GO interface, and one P2P-device interface.

The line

#{ IBSS, managed, AP } <= 2, #{ P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1, total <= 3, #channels <= 2

means you can have at most two interfaces that are either IBSS, managed or AP (but can be the same), at most one P2P-client or P2P-go interface, and at most one P2P-device interface. But you can’t have more than three in total, so if you choose two from the first group, you can choose only one of the two last groups.

I haven’t tried to set up Wi-Fi Direct myself yet, but both restrictions on the P2P modes look similar, so I’d assume both should work with Wi-Fi Direct.