From 8b2b0be95bebff6847cdff4392aa3aae464bd094 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Mon, 23 May 2022 21:30:24 -0500 Subject: [PATCH] Ensuring we go through local networking for our VIPs --- bin/generate-pihole-dns-dhcp.py | 6 +++++- examples/msn0.yml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/generate-pihole-dns-dhcp.py b/bin/generate-pihole-dns-dhcp.py index 55852fb..dcf5646 100755 --- a/bin/generate-pihole-dns-dhcp.py +++ b/bin/generate-pihole-dns-dhcp.py @@ -9,6 +9,7 @@ # Author: DarkFeather import os +import subprocess import sys import yaml @@ -38,6 +39,8 @@ def WriteDNSEntry(content,hosttype,hostclass): global dnsfile with open(dnsfilepath,'a') as dnsfile: + + # Write host entries for host in content['all']['children'][hosttype]['children'][hostclass]['hosts']: try: dnsfile.write(content['all']['children'][hosttype]['children'][hostclass]['hosts'][host]['ip'] + ' ' + host + '.' + content['all']['vars']['replica_domain'] + ' ' + host + '\n') @@ -62,7 +65,8 @@ def GenerateFiles(file): dhcpfile.write('dhcp-option=option:dns-server,'+content['all']['vars']['dns']+'\n\n') dhcpfile.write('dhcp-range='+content['all']['vars']['staticrange']+'\n') with open(dnsfilepath,'w') as dnsfile: - dnsfile.write('') + vips=subprocess.run(["/bin/bash", "-c", "echo | openssl s_client -connect "+content['all']['vars']['external_domain']+":443 | openssl x509 -text -noout | grep DNS: | tr ',' '\n' | sed 's/\s\+DNS://' | egrep -iv ^"+content['all']['vars']['external_domain']+" | tr '\n' ' '"], capture_output=True).stdout.decode("utf-8") + dnsfile.write(content['all']['vars']['webfront']+' '+content['all']['vars']['external_domain']+' '+vips+"\n") # Add DNS entries for each host hosttype = 'managed' diff --git a/examples/msn0.yml b/examples/msn0.yml index edd11c8..859dd44 100644 --- a/examples/msn0.yml +++ b/examples/msn0.yml @@ -12,6 +12,7 @@ all: dns: "10.0.1.2" logserver: "10.0.1.16" ldapserver: "10.0.1.3" + webfront: "10.0.1.3" # Standards daemon_shell: /sbin/nologin user_shell: /bin/bash