Jessie wifi access point: Difference between revisions

From embeddedTS Manuals
(Add enable of systemd-networkd to wifi networking. Used for Stretch instructions when it defaults to no network setup)
(Clean up with formatting and style)
Line 1: Line 1:
First, hostapd needs to be installed in order to manage the access point on the device.
The 'hostapd' utility is used to manage the access point of the device. This is usually installed by default, but can be installed with:


<source lang=bash>
<source lang=bash>
Line 5: Line 5:
</source><br>
</source><br>


{{Note|The install process may start an unconfigured hostapd process.  This process must be killed before moving foward.}}
{{Note|The install process may start an unconfigured 'hostapd' process.  This process must be killed before moving forward.}}




Edit /etc/hostapd/hostapd.conf to have the following lines:
Modify the file "/etc/hostapd/hostapd.conf" to have the following lines:
<source lang=bash>
<source lang=bash>
ssid=YourWiFiName
ssid=YourWiFiName
Line 37: Line 37:
'''Systemd auto-start with bridge to eth0'''
'''Systemd auto-start with bridge to eth0'''


It is possible to configure the auto-start of hostapd through systemd.  The configuration outlined below will set up a bridge with eth0, meaning the WiFi connection is directly connected to the ethernet network.  The ethernet network is required to have a DHCP server present and active on it to assign WiFi clients a DHCP address.  This setup will allow WiFi clients access to the same network as the ethernet port, and the bridge interface will allow the Device itself to access the network.
It is possible to configure the auto-start of 'hostapd' through systemd.  The configuration outlined below will set up a bridge with "eth0", meaning the Wi-Fi connection is directly connected to the ethernet network.  The ethernet network is required to have a DHCP server present and active on it to assign Wi-Fi clients an IP address.  This setup will allow Wi-Fi clients access to the same network as the ethernet port, and the bridge interface will allow the platform itself to access the network.




'''Set up hostapd'''
'''Set up hostapd'''


First, create the file /etc/systemd/system/hostapd_user.service with the following contents:
First, create the file "/etc/systemd/system/hostapd_user.service" with the following contents:
<source lang=bash>
<source lang=bash>
[Unit]
[Unit]
Line 75: Line 75:




/etc/systemd/network/br0.netdev
"/etc/systemd/network/br0.netdev"
<source lang=bash>
<source lang=bash>
[NetDev]
[NetDev]
Line 83: Line 83:




/etc/systemd/network/br0.network
"/etc/systemd/network/br0.network"
<source lang=bash>
<source lang=bash>
[Match]
[Match]
Line 93: Line 93:




/etc/systemd/network/bridge.network
"/etc/systemd/network/bridge.network"
<source lang=bash>
<source lang=bash>
[Match]
[Match]

Revision as of 17:22, 9 July 2019

The 'hostapd' utility is used to manage the access point of the device. This is usually installed by default, but can be installed with:

apt-get update && apt-get install hostapd -y


Note: The install process may start an unconfigured 'hostapd' process. This process must be killed before moving forward.


Modify the file "/etc/hostapd/hostapd.conf" to have the following lines:

ssid=YourWiFiName
wpa_passphrase=Somepassphrase
interface=wlan0
bridge=br0
auth_algs=3
channel=7
driver=nl80211
hw_mode=g
logger_stdout=-1
logger_stdout_level=2
max_num_sta=5
rsn_pairwise=CCMP
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
Note: Refer to the kernel's hostapd documentation for more wireless configuration options.


The access point can be started and tested by hand:

hostapd /etc/hostapd/hostapd.conf


Systemd auto-start with bridge to eth0

It is possible to configure the auto-start of 'hostapd' through systemd. The configuration outlined below will set up a bridge with "eth0", meaning the Wi-Fi connection is directly connected to the ethernet network. The ethernet network is required to have a DHCP server present and active on it to assign Wi-Fi clients an IP address. This setup will allow Wi-Fi clients access to the same network as the ethernet port, and the bridge interface will allow the platform itself to access the network.


Set up hostapd

First, create the file "/etc/systemd/system/hostapd_user.service" with the following contents:

[Unit]
Description=Hostapd IEEE 802.11 AP
Wants=network.target
Before=network.target
Before=network.service
After=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-br0.device
BindsTo=sys-subsystem-net-devices-wlan0.device
BindsTo=sys-subsystem-net-devices-br0.device

[Service]
Type=forking
PIDFile=/run/hostapd.pid
ExecStart=/usr/sbin/hostapd /etc/hostapd/hostapd.conf -P /run/hostapd.pid -B

[Install]
WantedBy=multi-user.target

Then enable this in systemd:

systemctl enable hostapd_user.service
systemctl enable systemd-networkd


Set up bridging

Create the following files with the listed contents.


"/etc/systemd/network/br0.netdev"

[NetDev]
Name=br0
Kind=bridge


"/etc/systemd/network/br0.network"

[Match]
Name=br0

[Network]
DHCP=yes


"/etc/systemd/network/bridge.network"

[Match]
Name=eth0

[Network]
Bridge=br0