2021-02-08 13:42:35 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2021-03-30 14:01:53 +02:00
|
|
|
let password = builtins.readFile /var/keys/ddclient;
|
|
|
|
|
|
|
|
in {
|
2021-03-12 12:06:26 +01:00
|
|
|
# Assign a static IP
|
|
|
|
networking = {
|
2021-03-15 10:40:49 +01:00
|
|
|
hostName = "unit";
|
|
|
|
hostId = "737d82f4";
|
2021-03-12 12:06:26 +01:00
|
|
|
interfaces.eth0 = {
|
|
|
|
useDHCP = false;
|
2021-03-15 10:40:49 +01:00
|
|
|
ipv4.addresses = [{
|
2021-03-12 12:06:26 +01:00
|
|
|
address = "10.0.1.3";
|
|
|
|
prefixLength = 24;
|
2021-03-15 10:40:49 +01:00
|
|
|
}];
|
2021-03-12 12:06:26 +01:00
|
|
|
};
|
|
|
|
defaultGateway = {
|
|
|
|
address = "10.0.1.1";
|
|
|
|
interface = "eth0";
|
|
|
|
};
|
|
|
|
nameservers = [ "1.1.1.1" "8.8.8.8" ];
|
|
|
|
enableIPv6 = false;
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
# Enable zeroconf
|
|
|
|
services.avahi = {
|
|
|
|
enable = true;
|
|
|
|
nssmdns = true;
|
|
|
|
publish = {
|
|
|
|
enable = true;
|
2021-03-25 09:52:43 +01:00
|
|
|
addresses = true;
|
2021-02-08 13:42:35 +01:00
|
|
|
domain = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-30 14:01:53 +02:00
|
|
|
# Dynamic DNS configuration
|
|
|
|
services.ddclient = {
|
|
|
|
enable = true;
|
|
|
|
quiet = true;
|
|
|
|
protocol = "duckdns";
|
|
|
|
domains = [ "coace.duckdns.org" ];
|
|
|
|
inherit password;
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
# Firewall configuration
|
|
|
|
networking.firewall = {
|
2021-03-12 12:06:26 +01:00
|
|
|
allowedTCPPorts = [
|
|
|
|
445 # Samba
|
|
|
|
139 # Samba
|
2021-03-25 09:52:43 +01:00
|
|
|
2222 # VM SSH
|
2021-03-19 11:13:25 +01:00
|
|
|
5000 # Sybase
|
2021-03-12 12:06:26 +01:00
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
|
|
|
137 # Samba
|
|
|
|
138 # Samba
|
|
|
|
1194 # Wireguard
|
|
|
|
];
|
2021-03-19 11:13:25 +01:00
|
|
|
allowPing = true;
|
2021-02-08 13:42:35 +01:00
|
|
|
};
|
|
|
|
|
2021-03-25 09:52:43 +01:00
|
|
|
# Enable NAT for wireguard and forward ports to sica VM
|
2021-03-12 12:08:22 +01:00
|
|
|
networking.nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "eth0";
|
2021-03-25 09:52:43 +01:00
|
|
|
internalInterfaces = [ "wg0" "br0" ];
|
|
|
|
forwardPorts = [
|
|
|
|
{
|
|
|
|
destination = "192.168.122.100:22";
|
|
|
|
sourcePort = 2222;
|
2021-03-25 16:35:04 +01:00
|
|
|
loopbackIPs = [ "10.0.1.3" ];
|
2021-03-25 09:52:43 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
destination = "192.168.122.100:5000";
|
|
|
|
sourcePort = 5000;
|
2021-03-25 16:35:04 +01:00
|
|
|
loopbackIPs = [ "10.0.1.3" ];
|
2021-03-25 09:52:43 +01:00
|
|
|
}
|
|
|
|
];
|
2021-03-12 12:08:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Wireguard setup
|
|
|
|
networking.wireguard.interfaces = {
|
|
|
|
wg0 = {
|
|
|
|
ips = [ "10.9.0.1/24" ];
|
|
|
|
listenPort = 1194;
|
|
|
|
privateKeyFile = "/home/coace/.wg/keys/privatekey";
|
|
|
|
peers = [
|
2021-03-12 12:43:22 +01:00
|
|
|
# Amin
|
2021-03-12 12:08:22 +01:00
|
|
|
{
|
|
|
|
publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38=";
|
|
|
|
allowedIPs = [ "10.9.0.2/32" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-25 09:52:43 +01:00
|
|
|
# QEMU virtual bridge
|
|
|
|
networking.interfaces.br0 = {
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "192.168.122.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
networking.bridges.br0.interfaces = [ ];
|
|
|
|
|
|
|
|
services.dhcpd4 = {
|
|
|
|
enable = true;
|
|
|
|
interfaces = [ "br0" ];
|
|
|
|
extraConfig = ''
|
|
|
|
option routers 192.168.122.1;
|
|
|
|
option broadcast-address 192.168.122.255;
|
|
|
|
option subnet-mask 255.255.255.0;
|
|
|
|
option domain-name-servers 1.1.1.1, 8.8.8.8;
|
|
|
|
default-lease-time -1;
|
|
|
|
max-lease-time -1;
|
|
|
|
subnet 192.168.122.0 netmask 255.255.255.0 {
|
|
|
|
range 192.168.122.100 192.168.122.200;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
}
|