summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/lanparty
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2017-06-28 12:00:28 +0200
committermakefu <github@syntax-fehler.de>2017-06-28 12:00:28 +0200
commit2dd0b055588ee5bf3262ec138265a881df4c01a5 (patch)
treeaea0472a366570e42b340bc2b14dbdb32953765a /makefu/2configs/lanparty
parent984b7fd31b47bfbbee0e8adf8a1e6caa69376c2e (diff)
ma lancache-dns: init
Diffstat (limited to 'makefu/2configs/lanparty')
-rw-r--r--makefu/2configs/lanparty/lancache-dns.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/makefu/2configs/lanparty/lancache-dns.nix b/makefu/2configs/lanparty/lancache-dns.nix
new file mode 100644
index 000000000..4b4ebf0a0
--- /dev/null
+++ b/makefu/2configs/lanparty/lancache-dns.nix
@@ -0,0 +1,55 @@
+{ pkgs, lib, config, ... }:
+with import <stockholm/lib>;
+let
+ # see https://github.com/zeropingheroes/lancache for full docs
+ lancache-dns = pkgs.stdenv.mkDerivation rec {
+ name = "lancache-dns-2017-06-28";
+ src = pkgs.fetchFromGitHub {
+ # forked: https://github.com/zeropingheroes/lancache-dns
+ repo = "lancache-dns";
+ owner = "zeropingheroes";
+ rev = "420aa62";
+ sha256 = "0ik7by7ripdv2avyy5kk9jp1i7rz9ksc8xmg7n9iik365q9pv94m";
+ };
+ phases = [ "unpackPhase" "installPhase" ];
+ # here we can chance to edit `includes/proxy-cache-paths.conf`
+ installPhase = ''
+ mkdir -p $out
+ cp -r * $out/
+ '';
+ };
+ stateDir = "/var/lib/unbound";
+ user = "unbound";
+ upstream-server = "8.8.8.8";
+in {
+ services.unbound = {
+ enable = true;
+ allowedAccess = [ "10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16" ];
+ interfaces = ["0.0.0.0" "::" ];
+ forwardAddresses = [ upstream-server ];
+ extraConfig = ''
+ include: "${stateDir}/lancache/*.conf"
+ '';
+ };
+ services.dnscrypt-proxy.enable = lib.mkForce false;
+ virtualisation.libvirtd.enable = lib.mkForce false;
+ systemd.services.dns-lancache-prepare = {
+ wantedBy = [ "unbound.service" ];
+ before = [ "unbound.service" ];
+ after = [ "network-online.target" ];
+ partOf= [ "unbound.service" ];
+
+ path = [ pkgs.gawk pkgs.iproute pkgs.gnused ];
+ script = ''
+ set -xeu
+ current_ip=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}')
+ old_ip=10.1.1.250
+ mkdir -p ${stateDir}
+ rm -rvf ${stateDir}/lancache
+ cp -r ${lancache-dns}/upstreams-available ${stateDir}/lancache
+ sed -i "s/$old_ip/$current_ip/g" ${stateDir}/lancache/*.conf
+ chown -R unbound ${stateDir}
+ '';
+ };
+ networking.firewall.allowedUDPPorts = [ 53 ];
+}