102 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Markdown
		
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Markdown
		
	
	
	
| +++
 | |
| title = "Access Point on a Raspberry Pi"
 | |
| date = 2020-09-26
 | |
| tags = ["admin"]
 | |
| +++
 | |
| The Raspberry Pi family who have wireless capabilities can all serve as wifi
 | |
| Access Points - meaning some other devices connect to it, perhaps accessing
 | |
| internet through it. We'll leave the "forward internet" part for another
 | |
| time, and concentrate on serving wifi connections as a hotspot.
 | |
| 
 | |
| If what you need is a "rescue" Access Point to be able to log back into the
 | |
| machine, you might rather check my other article on [RPi basics][arch-on-rpi],
 | |
| where you will see how to let `wpa_supplicant` fall back to being an Access
 | |
| Point if it can't connect to any.
 | |
| 
 | |
| And for now let's use `hostapd`, a package to implement and advertise a wifi
 | |
| access point. It might be a better option for production use since it's a
 | |
| dedicated tool, whereas `wpa_supplicant` is a bit out of its league here.
 | |
| 
 | |
| `hostapd` needs the interface to be up and configured with an IP.  So we'll
 | |
| configure `systemd-networkd` to do that, and by the way propose an IP address to
 | |
| clients that get connected to our AP. Change
 | |
| `/etc/systemd/network/05-wlan.network` so that it reads :
 | |
| ``` systemd
 | |
| [Network]
 | |
| Address=192.168.1.1
 | |
| DHCPServer=true
 | |
| IPMasquerade=true
 | |
| IPForward=true
 | |
| 
 | |
| [DHCPServer]
 | |
| PoolOffset=100
 | |
| PoolSize=20
 | |
| EmitDNS=true
 | |
| ```
 | |
| Now `hostapd` won't work (at least in this configuration) if you have
 | |
| `wpa_supplicant` installed. Go on and 
 | |
| ```
 | |
| # pacman -Rs wpa_supplicant
 | |
| ```
 | |
| And last, you will need to tweak `/etc/hostapd/hostapd.conf`. This one was taken
 | |
| from [Archwiki's][aw-ap], and curated for RPi zero W :
 | |
| ```
 | |
| interface=wlan0
 | |
| #bridge=br0
 | |
| # Country code (ISO/IEC 3166-1)
 | |
| country_code=FR
 | |
| 
 | |
| # SSID to be used in IEEE 802.11 management frames
 | |
| ssid=zero
 | |
| wpa_passphrase=YOUR_PASSWORD_HERE
 | |
| 
 | |
| # Driver interface type (hostap/wired/none/nl80211/bsd) - default hostapd
 | |
| #driver=rtl871xdrv
 | |
| #driver=nl80211
 | |
| 
 | |
| # Operation mode (a = IEEE 802.11a (5 GHz), b = IEEE 802.11b (2.4 GHz)
 | |
| # RPi zero W only supports b
 | |
| hw_mode=b
 | |
| # Channel number
 | |
| channel=5
 | |
| # Maximum number of stations allowed
 | |
| max_num_sta=5
 | |
| 
 | |
| # Bit field: bit0 = WPA, bit1 = WPA2
 | |
| wpa=2
 | |
| # Bit field: 1=wpa, 2=wep, 3=both
 | |
| auth_algs=1
 | |
| 
 | |
| # Set of accepted cipher suites; disabling insecure TKIP
 | |
| wpa_pairwise=CCMP
 | |
| # Set of accepted key management algorithms
 | |
| wpa_key_mgmt=WPA-PSK
 | |
| 
 | |
| # hostapd event logger configuration
 | |
| logger_stdout=-1
 | |
| #  0 = verbose debugging
 | |
| #  1 = debugging
 | |
| #  2 = informational messages
 | |
| #  3 = notification
 | |
| #  4 = warning
 | |
| logger_stdout_level=2
 | |
| 
 | |
| ## QoS support
 | |
| #wmm_enabled=1
 | |
| ## Use "iw list" to show device capabilities and modify ht_capab accordingly
 | |
| #ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
 | |
| ht_capab=[HT20][TX-STBC1][DSSS_CCK-40]
 | |
| ```
 | |
| 
 | |
| If you use a Realtek-based wifi adapter, there is a specific hostapd package for
 | |
| hosts using rtl871 hardware. You will have to install it from the AUR ; you will
 | |
| have to
 | |
| ```
 | |
| $ yay -S hostapd-rtl871xrdv
 | |
| ```
 | |
| _And_ modify `/etc/hostapd/hostapd.conf` to mention `driver=rtl871xdrv`.
 | |
| 
 | |
| [arch-on-rpi]: {{< relref arch-on-rpi >}}
 | |
| [aw-ap]: https://wiki.archlinux.org/index.php/Software_access_point
 | |
| 
 |