Eigenen DynDNS Server
Noch in Bearbeitung
Script
Datenbank erstellen
create database if not exists ddns; grant all on ddns.* to 'powerdns'@'localhost';
CREATE TABLE ddns_hosts ( id INT NOT NULL AUTO_INCREMENT, hostname VARCHAR(64) NOT NULL, password VARCHAR(64) NOT NULL, PRIMARY KEY (id) );
INSERT INTO ddns_hosts ( hostname, password ) VALUES ( 'zuhause', 'abc123' );
Script
<?php $mysqli = new mysqli("127.0.0.1", "powerdns", "M7kWxyTCct", "ddns"); /* check connection */ if (mysqli_connect_errno()) { die("Verbindung fehlgeschlagen: " . mysqli_connect_error()); } $host = mysqli_real_escape_string($mysqli, $_GET['host']); $pass1 = mysqli_real_escape_string($mysqli, $_GET['pass']); /* Select queries return a resultset */ if ($query = $mysqli->query("SELECT password FROM ddns_hosts WHERE hostname = '" . $host . "'")) { if ($row = mysqli_fetch_assoc($query)) { $pass2 = $row["password"]; } else { invalidCredentials(); } /* free result set */ $query->close(); } else { printf("Invalid query: %s\n", mysqli_error($mysqli)); exit(); } if ($pass1 != $pass2) { invalidCredentials(); } else { /* change db to powerdns_admin db */ $mysqli->select_db("powerdns"); if (!$ip=$_SERVER['HTTP_X_FORWARDED_FOR']) { $ip=$_SERVER['REMOTE_ADDR']; } $domain=$host.".example.com"; //$domain2="*.".$domain; if (!$result1 = $mysqli->query("UPDATE records SET content='$ip' WHERE name='$domain';")) { printf("Invalid query: %s\n", mysqli_error($mysqli)); exit(); } //$result2=mysql_query("UPDATE records SET content='$ip' WHERE name='$domain2';"); } function invalidCredentials() { die("Falsches Passwort oder unbekannter Host"); } ?>
http://ddns1.kirner.or.at/?host=zuhause&pass=abc123
Mit PowerDNS
Links
https://www.debacher.de/wiki/Mein_eigenes_DynDNS
https://controlc.de/2013/09/10/debian-selbstgehosteter-dyndns-dienst/
https://controlc.de/2014/08/25/debian-selbstgehosteter-dyndns-dienst-der-client-teil/#more-2532)
http://nicht-traeumen-sondern-machen.de/RaspberryPi_Basteleien/DynDNS_mit_Fritzbox.php
Zurück zu Ubuntu