PowerShell
Bind & DDNS & PowerShell
Den Key erstellt Ihr euch über SSH mit folgendem Befehl Achtung: Domainname natürlich mit eurem ersetzen! ddns-confgen -a hmac-sha512 -z Domainname
Example: Named.conf
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; }; // listen-on-v6 port 53 { ::1; }; // filter-aaaa-on-v4 yes; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; secroots-file "/var/named/data/named.secroots"; recursing-file "/var/named/data/named.recursing"; allow-query { any; }; allow-transfer { EDITED; }; notify yes; also-notify { EDITED; }; /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; dnssec-validation auto; managed-keys-directory "/var/named/dynamic"; geoip-directory "/usr/share/GeoIP"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */ include "/etc/crypto-policies/back-ends/bind.config"; forwarders { EDITED; 8.8.8.8; 8.8.4.4; }; // dnssec-enable yes; // dnssec-enable yes; }; logging { channel default_debug { file "/var/log/named.run"; }; }; zone "." IN { type hint; file "named.ca"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; key rndc-key { algorithm hmac-sha256; secret "EDITED"; }; key "ddns-key.dyndns.datateam.center" { algorithm hmac-sha512; secret "Euer generierter Key"; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { rndc-key; }; }; server EDITED { }; zone "datateam.center" { type master; file "/var/named/datateam.center.hosts"; also-notify { EDITED; }; notify yes; update-policy { grant ddns-key.dyndns.datateam.center zonesub ANY; }; allow-transfer { 127.0.0.1; EDITED; }; };
I edited some things and replaced them with EDITED – so be careful
What is actually just added is the following:
key "ddns-key.dyndns.datateam.center" { algorithm hmac-sha512; secret "Euer generierter Key"; }; Unter der Zone kommt folgendes: update-policy { grant ddns-key.dyndns.datateam.center zonesub ANY; };
You will receive exactly what is entered when you generate your key.
Example: Key File
key "ddns-key.dyndns.datateam.center" { algorithm hmac-sha512; secret "Euer generierter Key"; };
PowerShell Script
<# Get full info: $providerinfo = Invoke-RestMethod http://ipinfo.io/json #> Param ( [String]$KeyPath = "C:\dyndns\dyndns.datateam.center.key", [String]$NSScriptPath = "c:\dyndns\nsupdate.txt", [String]$NSUpdatePath = "C:\dyndns" ) begin { #Gather status of system IP Addresses, DNS Servers, and domains $myip = (Invoke-WebRequest -uri "https://api.ipify.org/").Content $servername = "ns1.datateam.center" $dnszone = "datateam.center" $hostname = "holodeck.$dnszone" } process { $script = "update delete $hostname update add $hostname. 60 A $myip " } end { $script | Out-File -FilePath $NSScriptPath -Encoding "ascii" -Force Start-Process -FilePath (Join-Path -Path $NSUpdatePath -ChildPath "nsupdate.exe") -ArgumentList "-d -k `"$KeyPath`" `"$NSScriptPath`"" -Wait -NoNewWindow -RedirectStandardError "c:\dyndns\nsstderr.log" -RedirectStandardOutput "c:\dyndns\nsstdout.log" -WorkingDirectory $NSUpdatePath | Out-Null }
Here I created the dyndns directory on C: on a Windows computer.
Below I copied the DLL files and nsupdate.exe from the ZIP file from the Bind DNS server.
I also have Bind in my downloads here on this server.
dyndns.datateam.center.key is the file with the generated key. You can name it whatever you want, you just have to adapt the PowerShell file 🙂
Subscribe
Login
0 Comments
Oldest