Raspberry Pi as Standalone Access Point: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
No edit summary
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
WIP - WIP - WIP
I had a case ([[Raspberry Pi Zero ePaper Nametag]]), where I needed an Raspberry Pi Zero WH to act as access point, including DHCP-Server. Standalone, not connected to any network.
 
 
 
 
I had a case (that has yet to be documented here), where I needed an Raspberry Pi Zero WH to act as access point, including DHCP-Server. Standalone, not connected to any network.


= Installation =
= Installation =
  apt-get install hostapd dnsutils traceroute isc-dhcp-server
  apt-get install hostapd dnsutils traceroute udhcp


= Configuration =
= Configuration =
Line 15: Line 10:
  net.ipv6.conf.all.disable_ipv6=1
  net.ipv6.conf.all.disable_ipv6=1
Explanation: Disable [[IPv6]] (to [[KISS]]).
Explanation: Disable [[IPv6]] (to [[KISS]]).
== Disable wpa-supplicant ==
If the Pi was used before, WPA-supplicant was most likely set up. Disable it.
== Setup DHCPd ==
vi /etc/udhcpd.conf
…and…
start 10.178.42.100 # This is the range of IPs that the hostspot will give to client devices.
end 10.178.42.199
interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns 10.178.42.1
opt subnet 255.255.255.0
opt router 10.178.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds
…and…
vi /etc/default/udhcpd
…and comment this out…
#DHCPD_ENABLED="no"


== Enable and Configure Access Point ==
== Enable and Configure Access Point ==
Line 25: Line 39:
  interface=wlan0
  interface=wlan0
  driver=nl80211
  driver=nl80211
bridge=br0 ????????????
  hw_mode=g
  hw_mode=g
  channel=7
  channel=7
Line 39: Line 52:
  ssid=HMS_Camden_Lock
  ssid=HMS_Camden_Lock
  wpa_passphrase=42_42_42_42
  wpa_passphrase=42_42_42_42
Explanation: <tt>hostapd</tt> creates the [[WiFi]]-Access Point and creates a bridge-device <tt>br0</tt>, which he ties (only) <tt>wlan0</tt> to<ref>Check with: <tt>brctl show</tt></ref>.  
country_code=DE
----
 
Enable it
vi /etc/default/hostapd
…and comment this and set path:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
 
== Set static IP-Address ==
  vi /etc/dhcpcd.conf
  vi /etc/dhcpcd.conf
and set something like this:
…and…
  nohook wpa_supplicant ????
  interface wlan0
denyinterfaces wlan0 ????
  static ip_address=10.178.42.1/24
Explanation: I omit <tt>/etc/wpa_supplicant/wpa_supplicant.conf</tt> for <tt>wlan0</tt>. It is essential that there remains only one layer3-active (meaning using IP) interface, and that is <tt>br0</tt>. Otherwise you get a routing mess.
  static routers=10.178.42.1
Since <tt>br0</tt> and <tt>eth0</tt> are not omitted (denied), they get [[IPA]]s from the [[DHCP]]-Server. That's necessary for <tt>br0</tt>, and not for <tt>eth0</tt> (but when I omitted <tt>eth0</tt>, the bridge didn't come up. So I removed the [[IPA]] later (see below).
  static domain_name_servers=10.178.42.1
== Launch AP and DHCPd ==
service hostapd start
service udhcpd start
 
== Known issues ==
root@pi00:~# service hostapd start
Failed to start hostapd.service: Unit hostapd.service is masked.
root@pi00:~#
 
systemctl unmask hostapd
systemctl enable hostapd


== Enable and Configure DHCPd ==
Also remember: Try setting WiFi-Country with…
vi /etc/dhcp/dhcpd.conf
  raspi-config
…set…
…first!
default-lease-time 600;
  max-lease-time 7200;
…un-comment this:
authoritative;
…set your ip range:
subnet 10.178.42.0 netmask 255.255.255.0 {
  range 10.178.42.100 10.178.42.240;
#  option routers 10.178.somebyte.anotherbyte;
  option domain-name "pi00.wurst-wasser.net";
  option domain-name-servers 127.0.0.1;
}
Launch it:
systemctl start isc-dhcp-server.service


== Setup DNS ==
== Setup DNS ==
Line 77: Line 94:
** https://www.raspberry-pi-geek.de/ausgaben/rpg/2014/03/raspi-als-dhcp-und-dns-server/
** https://www.raspberry-pi-geek.de/ausgaben/rpg/2014/03/raspi-als-dhcp-und-dns-server/
** https://www.itsfullofstars.de/2019/02/dhcp-server-on-linux-with-raspberry-pi/
** https://www.itsfullofstars.de/2019/02/dhcp-server-on-linux-with-raspberry-pi/
** https://www.ionos.com/digitalguide/server/configuration/provide-raspberry-pi-with-a-static-ip-address/
** https://elinux.org/RPI-Wireless-Hotspot
* Footnotes
* Footnotes
<references/>
<references/>


[[Category:RaspberryPi]]
[[Category:RaspberryPi]]

Latest revision as of 16:33, 29 November 2020

I had a case (Raspberry Pi Zero ePaper Nametag), where I needed an Raspberry Pi Zero WH to act as access point, including DHCP-Server. Standalone, not connected to any network.

Installation

apt-get install hostapd dnsutils traceroute udhcp

Configuration

Disable IPv6

vi /etc/sysctl.conf

and set

net.ipv6.conf.all.disable_ipv6=1

Explanation: Disable IPv6 (to KISS).

Disable wpa-supplicant

If the Pi was used before, WPA-supplicant was most likely set up. Disable it.

Setup DHCPd

vi /etc/udhcpd.conf

…and…

start 10.178.42.100 # This is the range of IPs that the hostspot will give to client devices.
end 10.178.42.199
interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns 10.178.42.1
opt subnet 255.255.255.0
opt router 10.178.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds

…and…

vi /etc/default/udhcpd

…and comment this out…

#DHCPD_ENABLED="no"

Enable and Configure Access Point

vi /etc/default/hostapd 

and set:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Explanation: The hostapd reads the configfile, to find this configfile. I don't get what this is good for. I think I'm just net getting the whole concept. If anyone cares to enlighten me, please do. :)

vi /etc/hostapd/hostapd.conf

and set something like this:

interface=wlan0
driver=nl80211
hw_mode=g
channel=7
ieee80211n=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=HMS_Camden_Lock
wpa_passphrase=42_42_42_42
country_code=DE

Enable it

vi /etc/default/hostapd

…and comment this and set path:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Set static IP-Address

vi /etc/dhcpcd.conf

…and…

interface wlan0
  static ip_address=10.178.42.1/24
  static routers=10.178.42.1
  static domain_name_servers=10.178.42.1

Launch AP and DHCPd

service hostapd start
service udhcpd start

Known issues

root@pi00:~# service hostapd start
Failed to start hostapd.service: Unit hostapd.service is masked.
root@pi00:~# 
systemctl unmask hostapd
systemctl enable hostapd

Also remember: Try setting WiFi-Country with…

raspi-config

…first!

Setup DNS

Later. Not mattering right now.

Network Interfaces

vi /etc/network/interfaces

Don't touch this file. dhcpcd gets jealous...