Jessie wifi access point: Difference between revisions

From embeddedTS Manuals
(Initial creation)
 
(Used different text box formatting)
Line 8: Line 8:


Edit /etc/hostapd/hostapd.conf to have the following lines:
Edit /etc/hostapd/hostapd.conf to have the following lines:
<pre>
<source lang=bash>
ssid=YourWiFiName
ssid=YourWiFiName
wpa_passphrase=Somepassphrase
wpa_passphrase=Somepassphrase
Line 24: Line 24:
wpa_key_mgmt=WPA-PSK
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_pairwise=TKIP CCMP
</pre>
</source>
{{Note|Refer to the [http://wireless.kernel.org/en/users/Documentation/hostapd kernel's hostapd documentation] for more wireless configuration options.}}
{{Note|Refer to the [http://wireless.kernel.org/en/users/Documentation/hostapd kernel's hostapd documentation] for more wireless configuration options.}}


Line 42: Line 42:


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:
<pre>
<source lang=bash>
[Unit]
[Unit]
Description=Hostapd IEEE 802.11 AP
Description=Hostapd IEEE 802.11 AP
Line 60: Line 60:
[Install]
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
</pre>
</source>


Then enable this in systemd:
Then enable this in systemd:
Line 74: Line 74:


/etc/systemd/network/br0.netdev
/etc/systemd/network/br0.netdev
<pre>
<source lang=bash>
[NetDev]
[NetDev]
Name=br0
Name=br0
Kind=bridge
Kind=bridge
</pre>
</source>




/etc/systemd/network/br0.network
/etc/systemd/network/br0.network
<pre>
<source lang=bash>
[Match]
[Match]
Name=br0
Name=br0
Line 88: Line 88:
[Network]
[Network]
DHCP=yes
DHCP=yes
</pre>
</source>




/etc/systemd/network/bridge.network
/etc/systemd/network/bridge.network
<pre>
<source lang=bash>
[Match]
[Match]
Name=eth0
Name=eth0
Line 98: Line 98:
[Network]
[Network]
Bridge=br0
Bridge=br0
</pre>
</source>

Revision as of 16:47, 18 July 2017

First, hostapd needs to be installed in order to manage the access point on the device. Additionally, it is strongly recommended to install haveged, a tool for increasing system entropy. The extra entropy will allow for WPA2 connections to happen much more quickly:

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


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


Edit /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 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.


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


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