@cryptotaxi247 / infra-1 / commits / 6ae145c5

Forward prometheus metrics with wg0 too

Graham Christensen committed Sep 28, 2019 at 22:30 UTC 6ae145c5037d47a54d739ca0866fb3362d76fad1
1 file changed +8 -7
macs/host/networking.nix
+8 -7
@@ -33,13 +33,6 @@ in {
33 internalIPs = [
34 "${subnetIP}/24"
35 ];
36 - forwardPorts = [
37 - {
38 - destination = "${guestIP}:9100";
39 - proto = "tcp";
40 - sourcePort = 9101;
41 - }
42 - ];
36 };
37
38 networking.interfaces."tap0" = {
@@ -114,5 +107,13 @@ in {
107 '';
108 };
109
110 + systemd.services.forward-wg0-prometheus-to-guest = {
111 + wantedBy = [ "multi-user.target" ];
112 + script = ''
113 + set -euxo pipefail
114 + exec ${pkgs.socat}/bin/socat TCP-LISTEN:9101,fork,so-bindtodevice=${config.macosGuest.network.sshInterface} TCP:${guestIP}:9100
115 + '';
116 + };
117 +
118 };
119 }