-
Notifications
You must be signed in to change notification settings - Fork 1
/
configuration.nix
68 lines (60 loc) · 2.91 KB
/
configuration.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ pkgs, ... }: {
imports = [ <nixpkgs/nixos/modules/virtualisation/google-compute-image.nix> ];
# Configure the NAT/Firewall
networking.nat.enable = true;
networking.nat.externalInterface = "eth0";
networking.nat.internalInterfaces = [ "neutronvpn" ];
networking.firewall = {
allowedTCPPorts = [ 53 ];
allowedUDPPorts = [ 53 51820 ];
};
# Wireguard server
networking.wireguard.interfaces.neutronvpn = {
ips = [ "10.100.0.1/24" ];
listenPort = 51820;
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
postSetup = ''
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
'';
# This undoes the above command
postShutdown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
'';
privateKeyFile = "/home/hl/wireguard-keys/private";
peers = [
{ # iPhone de Hugo
publicKey = "BhT/7cESNyZRAvQ0j4MUDP+3EN4+l7A3saswuUkCLm8=";
allowedIPs = [ "10.100.0.2/32" ];
}
{ # RPI4A
publicKey = "Scj6DuWKk69aq+P/ZE795PTDYFYqL5kEVDM4D3eOigU=";
allowedIPs = [ "10.100.0.3/32" ];
}
];
};
# DNS Server
services.dnsmasq = {
enable = true;
extraConfig = ''
interface=neutronvpn
'';
};
# Install packages
environment.systemPackages = with pkgs; [
git vim dnsutils
];
security.sudo.wheelNeedsPassword = false;
users.extraUsers.hl = {
createHome = true;
home = "/home/hl";
description = "Hugo Lageneste";
group = "users";
extraGroups = [ "wheel" ];
useDef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