feat(iwd): use iwd as networkmanager backend and put wg port in var
This commit is contained in:
parent
d805d9c3e5
commit
24a4b6d124
1 changed files with 38 additions and 28 deletions
|
@ -1,34 +1,44 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
networking.firewall = {
|
networking = {
|
||||||
enable = true;
|
wireless.iwd.enable = true;
|
||||||
|
|
||||||
# Open ports in the firewall.
|
networkmanager.wifi.backend = "iwd";
|
||||||
allowedTCPPorts = [ ];
|
|
||||||
allowedUDPPorts = [ 51820 ];
|
|
||||||
allowedTCPPortRanges = [
|
|
||||||
{
|
|
||||||
from = 1714;
|
|
||||||
to = 1764;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
allowedUDPPortRanges = [
|
|
||||||
{
|
|
||||||
from = 1714;
|
|
||||||
to = 1764;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# if packets are still dropped, they will show up in dmesg
|
firewall =
|
||||||
logReversePathDrops = true;
|
let
|
||||||
# wireguard trips rpfilter up https://nixos.wiki/wiki/WireGuard#Setting_up_WireGuard_with_NetworkManager
|
wgPort = 51820;
|
||||||
extraCommands = ''
|
in
|
||||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN
|
{
|
||||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN
|
enable = true;
|
||||||
'';
|
|
||||||
extraStopCommands = ''
|
# Open ports in the firewall.
|
||||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true
|
allowedTCPPorts = [ ];
|
||||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true
|
allowedUDPPorts = [ wgPort ];
|
||||||
'';
|
allowedTCPPortRanges = [
|
||||||
|
{
|
||||||
|
from = 1714;
|
||||||
|
to = 1764;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
allowedUDPPortRanges = [
|
||||||
|
{
|
||||||
|
from = 1714;
|
||||||
|
to = 1764;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# if packets are still dropped, they will show up in dmesg
|
||||||
|
logReversePathDrops = true;
|
||||||
|
# wireguard trips rpfilter up https://nixos.wiki/wiki/WireGuard#Setting_up_WireGuard_with_NetworkManager
|
||||||
|
extraCommands = ''
|
||||||
|
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport ${toString wgPort} -j RETURN
|
||||||
|
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport ${toString wgPort} -j RETURN
|
||||||
|
'';
|
||||||
|
extraStopCommands = ''
|
||||||
|
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport ${toString wgPort} -j RETURN || true
|
||||||
|
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport ${toString wgPort} -j RETURN || true
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue