1. Configure a wlan interface on hotspot mode[edit | edit source]
- Configure the wlan interface for systemd/netword
Add the following rule on /lib/systemd/network/
cat /lib/systemd/network/hostapd.network [Match] Name=wlan0 [Network] Address=192.168.72.1/24 DHCPServer=yes IPForward=ipv4 IPMasquerade=yes
192.168.72.1/24: ip address affected to the hotspot device.
This configuration supports dhcpserver, ip forward and ip masquerade for this wlan interface: wlan0.
- Create the hotspot configuration by replacing /etc/hostapd.config content by the following lines
cat /etc/hostapd.conf interface=wlan0 driver=nl80211 # mode Wi-Fi (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g) hw_mode=g ssid=STExampleNetwork channel=7 wmm_enabled=0 macaddr_acl=0 # Wi-Fi closed, need an authentication auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=ExamplePassphareNetwork wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
STExampleNetwork is the visible name of the new wlan hotspot (SSID).
ExamplePassphareNetwork is the passphare associated to the wlan hotspot (SSID).
- Correct one issue with systemd-networkd.service which does not enable the wifi link by default
Add the highlighted line in /lib/systemd/system/hostapd.service file
cat /lib/systemd/system/hostapd.service [Service] ExecStartPre=/sbin/ip link set wlan0 up ExecStart=/usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B
- Enable systemd service
systemctl enable hostapd
2. How to configure a gateway configuration[edit | edit source]
For this example of configuration, the setup is:
- wlan0: wireless interface connected to SSID_NETWORK with DHCP
- eth0: ethernet interface with static IP which also have a DHCPserver on it
- forward of packet are activated between the two network interfaces.
2.1. Configure wireless interface[edit | edit source]
cat /lib/systemd/network/wlan0.network
[Match]
Name=wlan0
[Network]
DHCP=ipv4
IPForward=ipv4
- IPForward
- permit to forward all network packet from wireless network to other network.
Configure wireless interface for SSID_NETWORK network:
mkdir -p /etc/wpa_supplicant/ echo "ctrl_interface=/var/run/wpa_supplicant" > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf echo "eapol_version=1" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf echo "ap_scan=1" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf echo "fast_reauth=1" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf echo "" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf wpa_passphrase SSID_NETWORK PASSWORD_NETWORK >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf or wpa_passphrase SSID_NETWORK >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Where SSID_NETWORK PASSWORD_NETWORK correspond to the SSID and password of wireless network.
Enable the wireless configuration (to be take into account after reboot):
systemctl enable wpa_supplicant@wlan0.service systemctl restart systemd-networkd.service systemctl restart wpa_supplicant@wlan0.service