jike106397 发表于 2013-11-28 18:09:28

Centos 做自己的DDNS服务器

本帖最后由 jike106397 于 2013-11-28 18:19 编辑

简单做了个DDNS服务器,测试成功!!分享下
以下从自己WIKI上拷的,有问题请指正


1 install CENTOS
2 install BIND , APACHE and PHP
3 the configure file of bind:
      memstatistics-file "/var/named/data/named_mem_stats.txt";
      allow-query   { any; };
      recursion yes;

      dnssec-enable yes;
      dnssec-validation yes;
      dnssec-lookaside auto;

      /* Path to ISC DLV key */
      bindkeys-file "/etc/named.iscdlv.key";

      managed-keys-directory "/var/named/dynamic";
};

logging {
      channel default_debug {
                file "data/named.run";
                severity dynamic;
      };
};

zone "." IN {
      type hint;
      file "named.ca";
};

zone "d.dshoub。com."
{
      type master;
      file "named.d.dshoub。com";
      allow-query { any;};
      allow-update {127.0.0.1; };
      notify yes;
};



include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
4 the script file of php

<?php
$dns= $_GET["dns"];
$domain = "d.dshoub。com";
$ip = $_SERVER['REMOTE_ADDR'];
if (strlen($dns) > strlen($domain))
{
        if ( substr($dns,strlen($dns) - strlen($domain),strlen($domain)) == $domain )
        {
                shell_exec("/usr/bin/nsupdate<<EOF
                server 127.0.0.1
                zone $domain
                update delete $dns A
                update add $dns 300 A $ip
                send
                EOF
                ");
        }               
}
print $ip;
print "<br>";
print("updated $dns" .PHP_EOL);
?>
5how to use to update
HTTP://url/ddns。php?dns=<here is you dns name>
6 Script in MikroTik to update dns
:local url"http://d.dshoub。com/ddns.php\?dns=www。d.dshoub.com"
/tool fetch url=$urlmode=http keep-result=no
:log info message= [:resolve www。d.dshoub.com server=d.dshoub.com]

charley 发表于 2013-11-28 20:24:35

首先你要到域名商哪里吧你的DNS解析服务器指向你的服务器,不然这样有用吗?
页: [1]
查看完整版本: Centos 做自己的DDNS服务器