neige d'aoust

knowledge, art, and other stuff

User Tools

Site Tools


wifi_ap_diskless

This is an old revision of the document!


Wi-Fi access point on a diskless system

So I found a PCI Wi-Fi 5 (802.11ac) device (based on Intel Dual Band Wireless-AC 3168), and I decided to put it in my diskless system that boots Arch Linux from NFS, and turn it into a Wi-Fi access point, hoping to improve reception in my living room. Should be easy, right?

The problem

We're gonna use hostapd for this. The problem is, hostapd will want to bridge the Ethernet connection to the Wi-Fi device, which means temporarily shutting down Ethernet while creating a bridged connection, a thing the NFS client won't like at all and will throw the whole system into a nasty I/O deadlock.

Solution: creating that bridge in the initramfs, ideally before the root is mounted and at the same time the system brings up the networking.

We could also make a NAT, which would avoid the creation of a bridge, but that's boring, and I don't want a NAT inside of my NAT. The devices connected to the access point should be able to join my home network on the same level as all my other devices connected via wired or other access points.
/usr/bin/bridge-add
#!/bin/sh
 
ip link add name $2 type bridge
ip link set dev $2 up
ip link set $1 up
ip link set $1 master $2
/usr/lib/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<wired MAC address>", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eno1", RUN+="/usr/bin/bridge-add eno1 br0"
Don't forget to replace eno1 with your actual wired device name and add its MAC address! Also, make bridge-add executable with chmod +x /usr/bin/bridge-add.

Add the correct modules and files to your initramfs generator config:

/etc/mkinitcpio.conf
MODULES=(nfsv4 bridge)
BINARIES=(/usr/bin/mount.nfs4 /usr/bin/bridge-add)
FILES=(/usr/lib/udev/rules.d/70-persistent-net.rules)

Then you can replace eth0 with br0 in your kernel command line on your bootloader:

ip=:::::br0:dhcp nfsroot=192.168.1.10:/arch

Run mkinitcpio, reboot, and hopefully you have a usable system again, but now with a br0 device.

Now you can continue with the instructions on Software access point.

Configure the access point

Ideally you want to configure hostapd.conf with hw_mode=a to use Wi-Fi 5 (aka 802.11ac) capabilities and use the 5 GHz band, for Wi-Fi 4 (802.11n) and the 2.4 GHz band you can use hw_mode=g.

Seems I can't use the 5 GHz band on my Intel card1), patch kernel?

Solution: Apparently hostapd resets the regdomain before starting and it doesn't scan beforehand so the Intel LAR sets it correctly again, use this patch so the regdomain can be properly set and you can access the 5 GHz band, no kernel recompile needed. Well, unless there's no wi-fi signal around…

Also, the wireless interface may or may not show up right at boot unless you modprobe iwlmvm, make sure you either add it to /etc/modules-load.d or also /etc/mkinitcpio.conf.

Wired ethernet

For good measure I added a PCI card with a couple Ethernet ports, you'll want to add them to the bridge on boot, but of course using any sort of network manager may deadlock the system because it attempted to reconfigure every available interface at boot even though they're already configured. But this time, you don't need to configure them in initramfs, so a systemd unit will be more than enough.

/usr/local/bin/bridge-join
#!/bin/sh
ip link set $1 up
ip link set $1 master $2
/etc/systemd/system/[email protected]
[Unit]
Description=Bridge interface %I with br0
Requires=sys-subsystem-net-devices-br0.device
Requires=sys-subsystem-net-devices-enp3s0f0.device
Requires=sys-subsystem-net-devices-enp3s0f1.device
After=network.target
After=sys-subsystem-net-devices-br0.device
After=sys-subsystem-net-devices-enp3s0f0.device
After=sys-subsystem-net-devices-enp3s0f1.device
[Service]
Type=oneshot
ExecStart=/usr/local/bin/bridge-join %I br0
[Install]
WantedBy=multi-user.target
# systemctl enable bridge-interface@enp3s0f0 bridge-interface@enp3s0f1

See also

wifi_ap_diskless.1750124422.txt.gz · Last modified: by Yuki