-
-
Save grahamc/15f73122e4b7605f7b747d16af82ca06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, ... }: | |
let | |
externalInterface = "enp9s0"; | |
wirelessInterface = "wlp8s0"; | |
internalWiredInterfaces = [ | |
# "enp3s0" | |
"enp4s0" | |
# "enp6s0" | |
]; | |
internalInterfaces = [wirelessInterface ] ++ internalWiredInterfaces; | |
in | |
{ | |
boot.kernel.sysctl = { | |
"net.ipv4.conf.all.forwarding" = 1; | |
"net.ipv4.conf.default.forwarding" = 1; | |
}; | |
networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. | |
services.openssh.enable = true; | |
networking.firewall = { | |
enable = true; | |
allowedTCPPorts = [ 22 ]; | |
}; | |
networking.interfaces."${wirelessInterface}" = { | |
ip4 = [{ | |
address = "10.5.2.1"; | |
prefixLength = 24; | |
}]; | |
}; | |
networking.interfaces."enp4s0" = { | |
ip4 = [{ | |
address = "10.5.3.1"; | |
prefixLength = 24; | |
}]; | |
}; | |
networking.nat = { | |
enable = true; | |
externalInterface = externalInterface; | |
internalInterfaces = internalInterfaces; | |
internalIPs = [ | |
"10.5.2.0/24" | |
"10.5.3.0/24" | |
]; | |
}; | |
services.hostapd = { | |
enable = true; | |
wpa = false; | |
ssid = "CHANGEME"; | |
channel = 2; # Was 9, but 0 means search for best, and 36 seems best by Apple... 2 was best for 2.4ghz | |
interface = wirelessInterface; | |
hwMode = "g"; # was "g" but "a" for 5GHz? | |
extraConfig = '' | |
auth_algs=1 | |
wpa=2 | |
wpa_passphrase=CHANGEME | |
wpa_key_mgmt=WPA-PSK | |
rsn_pairwise=CCMP | |
channel=0 | |
wpa_pairwise=TKIP CCMP | |
ieee80211d=1 | |
ieee80211h=1 | |
ieee80211n=1 | |
ieee80211ac=1 | |
country_code=US | |
''; | |
# channel=0 | |
# ieee80211d=1 | |
# country_code=US | |
# ieee80211n=1 | |
# ieee80211ac=1 | |
}; | |
services.dhcpd = { | |
enable = true; | |
interfaces = internalInterfaces; | |
extraConfig = '' | |
option subnet-mask 255.255.255.0; | |
option broadcast-address 10.5.2.255; | |
option routers 10.5.2.1; | |
option domain-name-servers 4.2.2.1, 4.2.2.2, 4.2.2.3; | |
option domain-name "CHANGEME"; | |
subnet 10.5.2.0 netmask 255.255.255.0 { | |
range 10.5.2.100 10.5.2.200; | |
} | |
subnet 10.5.3.0 netmask 255.255.255.0 { | |
range 10.5.3.100 10.5.3.200; | |
} | |
''; | |
}; | |
# The NixOS release to be compatible with for stateful data such as databases. | |
system.stateVersion = "16.09"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment