Extract external interface into own variable
This commit is contained in:
parent
f612ddfe3e
commit
8f43b3ae81
1 changed files with 7 additions and 6 deletions
|
|
@ -3,8 +3,8 @@
|
|||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
let extIface = "ens3";
|
||||
in {
|
||||
imports = [ # Include the results of the hardware scan.
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
# Binary Cache for Haskell.nix
|
||||
nix.settings.trusted-public-keys =
|
||||
[ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
|
||||
|
||||
#nix.binaryCaches = [ "https://hydra.iohk.io" ];
|
||||
|
||||
# Use the GRUB 2 boot loader.
|
||||
|
|
@ -47,7 +48,7 @@
|
|||
wireless.enable = false;
|
||||
useDHCP = false;
|
||||
enableIPv6 = false;
|
||||
interfaces.ens3.ipv4.addresses = [{
|
||||
interfaces.${extIface}.ipv4.addresses = [{
|
||||
address = "195.90.211.228";
|
||||
prefixLength = 22;
|
||||
}];
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
|
||||
# wireguard related config
|
||||
nat.enable = true;
|
||||
nat.externalInterface = "ens3";
|
||||
nat.externalInterface = extIface;
|
||||
nat.internalInterfaces = [ "wg0" ];
|
||||
|
||||
wireguard.interfaces = {
|
||||
|
|
@ -69,10 +70,10 @@
|
|||
listenPort = 42666;
|
||||
|
||||
postSetup = ''
|
||||
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o ens3 -j MASQUERADE
|
||||
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o ${extIface} -j MASQUERADE
|
||||
'';
|
||||
postShutdown = ''
|
||||
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.0.0.0/24 -o ens3 -j MASQUERADE
|
||||
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.0.0.0/24 -o ${extIface} -j MASQUERADE
|
||||
'';
|
||||
|
||||
privateKeyFile = config.age.secrets.wireguard-thrall.path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue