|
| 1 | +# |
| 2 | +# hostapd.nix |
| 3 | +# |
| 4 | + |
| 5 | +{ config, pkgs, ... }: |
| 6 | + |
| 7 | +let |
| 8 | + interface1 = "wlp35s0"; # e.g. 2.4GHz channel 6 |
| 9 | + interface2 = "wlp65s0"; # e.g. 5GHz channel 100 |
| 10 | + interface3 = "wlp70s0"; # e.g. 5GHz channel 149 |
| 11 | + |
| 12 | + commonHostapdSettings = '' |
| 13 | + ssid=myssid |
| 14 | + wpa=2 |
| 15 | + wpa_key_mgmt=SAE |
| 16 | + rsn_pairwise=CCMP |
| 17 | + sae_require_mfp=1 |
| 18 | + ieee80211w=2 |
| 19 | + ieee80211n=1 |
| 20 | + ieee80211ac=1 |
| 21 | + ieee80211ax=1 |
| 22 | + wmm_enabled=1 |
| 23 | +
|
| 24 | + # WMM tuning for Best Effort (AC_BE) |
| 25 | + wmm_ac_be_aifs=1 |
| 26 | + wmm_ac_be_cwmin=4 |
| 27 | + wmm_ac_be_cwmax=4 |
| 28 | + wmm_ac_be_txop_limit=32 |
| 29 | + wmm_ac_be_acm=0 |
| 30 | +
|
| 31 | + # 802.11r (Fast BSS Transition) |
| 32 | + ieee80211r=1 |
| 33 | + mobility_domain=4f57 |
| 34 | + ft_over_ds=1 |
| 35 | + ft_psk_generate_local=1 |
| 36 | + nas_identifier=myssid-ap |
| 37 | + ''; |
| 38 | +in |
| 39 | +{ |
| 40 | + services.hostapd = { |
| 41 | + enable = true; |
| 42 | + radios = { |
| 43 | + "${interface1}" = { |
| 44 | + config = pkgs.writeText "hostapd-1.conf" ('' |
| 45 | + interface=${interface1} |
| 46 | + hw_mode=g |
| 47 | + channel=6 |
| 48 | + ${commonHostapdSettings} |
| 49 | + ''); |
| 50 | + }; |
| 51 | + "${interface2}" = { |
| 52 | + config = pkgs.writeText "hostapd-2.conf" ('' |
| 53 | + interface=${interface2} |
| 54 | + hw_mode=a |
| 55 | + channel=100 |
| 56 | + ${commonHostapdSettings} |
| 57 | + ''); |
| 58 | + }; |
| 59 | + "${interface3}" = { |
| 60 | + config = pkgs.writeText "hostapd-3.conf" ('' |
| 61 | + interface=${interface3} |
| 62 | + hw_mode=a |
| 63 | + channel=149 |
| 64 | + ${commonHostapdSettings} |
| 65 | + ''); |
| 66 | + }; |
| 67 | + }; |
| 68 | + }; |
| 69 | + |
| 70 | + # Disable DHCP on all interfaces, use static IP or bridge later |
| 71 | + networking.interfaces.${interface1}.useDHCP = false; |
| 72 | + networking.interfaces.${interface2}.useDHCP = false; |
| 73 | + networking.interfaces.${interface3}.useDHCP = false; |
| 74 | + |
| 75 | + networking.interfaces.${interface1}.ipv4.addresses = [ { address = "192.168.30.1"; prefixLength = 24; } ]; |
| 76 | + networking.interfaces.${interface2}.ipv4.addresses = [ { address = "192.168.31.1"; prefixLength = 24; } ]; |
| 77 | + networking.interfaces.${interface3}.ipv4.addresses = [ { address = "192.168.32.1"; prefixLength = 24; } ]; |
| 78 | + |
| 79 | + networking.firewall.enable = true; |
| 80 | + networking.nat.enable = true; |
| 81 | + networking.nat.externalInterface = "enp1s0"; |
| 82 | +} |
0 commit comments