From 9c5b933befcd7fbaa038dbaebfaa63f2f12d7bac Mon Sep 17 00:00:00 2001 From: Denis Akimkin Date: Mon, 9 Mar 2015 00:52:36 +0200 Subject: [PATCH 1/8] Add support for Yandex.Mail for Domain DNS service (domain.yandex.com) Yandex's DNS management API reference is located at: https://api.yandex.com/domain/doc/about.xml --- README.md | 1 + ddclient | 153 ++++++++++++++++++++++++++++++++++++++- sample-etc_ddclient.conf | 8 ++ 3 files changed, 160 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index edd0dc7..0a9ec16 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Dynamic DNS services currently supported include: nsupdate - See nsupdate(1) and ddns-confgen(8) for details CloudFlare - See https://www.cloudflare.com/ for details Google - See http://www.google.com/domains for details + Yandex - See https://domain.yandex.com/ for details DDclient now supports many of cable/dsl broadband routers. diff --git a/ddclient b/ddclient index b0550f6..adca562 100755 --- a/ddclient +++ b/ddclient @@ -451,6 +451,9 @@ my %variables = ( 'googledomains-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'domains.google.com', undef), }, + 'yandex-common-defaults' => { + 'server' => setv(T_FQDNP, 1, 0, 1, 'pddimp.yandex.ru', undef), + }, ); my %services = ( 'dyndns1' => { @@ -625,6 +628,16 @@ my %services = ( $variables{'service-common-defaults'}, ), }, + 'yandex' => { + 'updateable' => undef, + 'update' => \&nic_yandex_update, + 'examples' => \&nic_yandex_examples, + 'variables' => merge( + { 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),}, + $variables{'yandex-common-defaults'}, + $variables{'service-common-defaults'}, + ), + }, ); $variables{'merged'} = merge($variables{'global-defaults'}, $variables{'service-common-defaults'}, @@ -1868,6 +1881,9 @@ sub geturl { my $url = shift || ''; my $login = shift || ''; my $password = shift || ''; + my $data = shift || ''; + my $headerref = shift || ''; + my %headers = $headerref ? %$headerref : (); my ($peer, $server, $port, $default_port, $use_ssl); my ($sd, $rq, $request, $reply); @@ -1908,17 +1924,36 @@ sub geturl { my $to = sprintf "%s%s", $server, $proxy ? " via proxy $peer:$port" : ""; verbose("CONNECT:", "%s", $to); - $request = "GET "; - $request .= "http://$server" if $proxy; + $request = $data ? "POST " : "GET "; + if (!$use_ssl) { + $request .= "http://$server" if $proxy; + } else { + $request .= "https://$server" if $proxy; + } $request .= "/$url HTTP/1.0\n"; $request .= "Host: $server\n"; + for my $header (keys %headers) { + $request .= "${header}: "; + $request .= "$headers{$header}\n"; + } my $auth = encode_base64("${login}:${password}", ""); $request .= "Authorization: Basic $auth\n" if $login || $password; $request .= "User-Agent: ${program}/${version}\n"; + if ($data) { + $request .= "Content-Type: application/x-www-form-urlencoded\n"; + $request .= "Content-Length: "; + $request .= length($data); + $request .= "\n"; + } $request .= "Connection: close\n"; $request .= "\n"; + if ($data) { + $request .= $data; + $request .= "\n"; + } + ## make sure newlines are for some pedantic proxy servers ($rq = $request) =~ s/\n/\r\n/g; @@ -4117,6 +4152,120 @@ sub nic_cloudflare_update { } } } +###################################################################### +## nic_yandex_examples +###################################################################### +sub nic_yandex_examples { + return < $config{$key}{'password'}); + + # FQDNs + for my $host (@hosts) { + delete $config{$host}{'wantip'}; + + info("setting IP address to %s for %s", $ip, $host); + verbose("UPDATE:","updating %s", $host); + + # Get record ID for host + my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?"; + $url .= "domain="; + $url .= $config{$key}{'login'}; + my $reply = geturl(opt('proxy'), $url, '', '', '', \%headers); + unless ($reply) { + failed("updating %s: Could not connect to %s.", $host, $config{$key}{'server'}); + last; + } + last if !header_ok($host, $reply); + + # Strip header + $reply =~ s/^.*?\n\n//s; + my $response = JSON::Any->jsonToObj($reply); + if ($response->{success} eq 'error') { + failed ("%s", $response->{error}); + next; + } + + # Pull the ID out of the json + my ($id) = map { $_->{fqdn} eq $host ? $_->{record_id} : () } @{ $response->{records} }; + unless($id) { + failed("updating %s: DNS record ID not found.", $host); + next; + } + + # Update the DNS record + $url = "https://$config{$host}{'server'}/api2/admin/dns/edit"; + my $data = "domain="; + $data .= $config{$key}{'login'}; + $data .= "&record_id="; + $data .= $id; + $data .= "&content="; + $data .= $ip if $ip; + + $reply = geturl(opt('proxy'), $url, '', '', $data, \%headers); + unless ($reply) { + failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'}); + last; + } + last if !header_ok($host, $reply); + + # Strip header + $reply =~ s/^.*?\n\n//s; + $response = JSON::Any->jsonToObj($reply); + if ($response->{success} eq 'error') { + failed ("%s", $response->{error}); + } else { + success ("%s -- Updated Successfully to %s", $host, $ip); + } + + # Cache + $config{$host}{'ip'} = $ip; + $config{$host}{'mtime'} = $now; + $config{$host}{'status'} = 'good'; + } + } +} ###################################################################### diff --git a/sample-etc_ddclient.conf b/sample-etc_ddclient.conf index de8bfbc..da42bd5 100644 --- a/sample-etc_ddclient.conf +++ b/sample-etc_ddclient.conf @@ -214,3 +214,11 @@ ssl=yes # use ssl-support. Works with # login=my-auto-generated-username, # password=my-auto-generated-password # my.domain.tld, otherhost.domain.tld + +## +## Yandex.Mail for Domain (domain.yandex.com) +## +# protocol=yandex, \ +# login=domain.tld, \ +# password=yandex-pdd-token \ +# my.domain.tld,other.domain.tld \ From 3feaf02ebbd48878bd89c307cdc49ad118b4ed0a Mon Sep 17 00:00:00 2001 From: Bumsik Kim Date: Wed, 20 Mar 2019 12:29:47 +0000 Subject: [PATCH 2/8] Add systemd sample and instruction --- README.md | 7 +++++++ sample-etc_systemd.service | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 sample-etc_systemd.service diff --git a/README.md b/README.md index 055b3c3..e522256 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,13 @@ INSTALLATION: vi /etc/ddclient/ddclient.conf -- and change hostnames, logins, and passwords appropriately + ## For those using systemd: + cp sample-etc_systemd.service /etc/systemd/system/ddclient.service + ## enable automatic startup when booting + systemctl enable ddclient.service + ## start the first time by hand + systemctl start ddclient.service + ## For those using Redhat style rc files and using daemon-mode: cp sample-etc_rc.d_init.d_ddclient /etc/rc.d/init.d/ddclient ## enable automatic startup when booting diff --git a/sample-etc_systemd.service b/sample-etc_systemd.service new file mode 100644 index 0000000..c6418a4 --- /dev/null +++ b/sample-etc_systemd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Dynamic DNS Update Client +After=network.target + +[Service] +Type=forking +PIDFile=/var/run/ddclient.pid +ExecStart=/usr/sbin/ddclient + +[Install] +WantedBy=multi-user.target From d90d6799d319e9c4fb09ab255602353548a15d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 6 Apr 2019 13:14:47 +0200 Subject: [PATCH 3/8] Fix fritz box example for newer routers --- sample-get-ip-from-fritzbox | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sample-get-ip-from-fritzbox b/sample-get-ip-from-fritzbox index 87b986e..c17e775 100755 --- a/sample-get-ip-from-fritzbox +++ b/sample-get-ip-from-fritzbox @@ -15,6 +15,6 @@ curl -s -H 'Content-Type: text/xml; charset="utf-8"' \ -H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \ - --data-binary '' \ - http://169.254.1.1:49000/upnp/control/WANCommonIFC1 | \ - sed -n -e 's#^.*\(.*\).*$#\1#p' + -d ' ' \ + 'http://fritz.box:49000/igdupnp/control/WANIPConn1' | \ + grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>' From 30dce80ad051f67c3b567569795303c7b6ee4ee3 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Apr 2019 17:27:22 +0200 Subject: [PATCH 4/8] Add support for dondominio.com --- README.md | 1 + README.ssl | 1 + ddclient | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/README.md b/README.md index 055b3c3..45efe4a 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Dynamic DNS services currently supported include: Duckdns - See https://duckdns.org/ for details Freemyip - See https://freemyip.com for details woima.fi - See https://woima.fi/ for details + DonDominio - See https://www.dondominio.com for details DDclient now supports many of cable/dsl broadband routers. diff --git a/README.ssl b/README.ssl index ed8d19b..34497b9 100644 --- a/README.ssl +++ b/README.ssl @@ -9,3 +9,4 @@ On alpine, you need perl-io-socket-ssl to have IO::Socket::SSL ssl support is tested on folowing dynamic dns providers: - dyndns.com - freemyip.com +- dondominio.com diff --git a/ddclient b/ddclient index 5f65d95..0e89215 100755 --- a/ddclient +++ b/ddclient @@ -483,6 +483,9 @@ my %variables = ( 'warned-min-interval' => setv(T_ANY, 0, 1, 0, 0, undef), 'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef), }, + 'dondominio-common-defaults' => { + 'server' => setv(T_FQDNP, 1, 0, 1, 'dondns.dondominio.com', undef), + }, ); my %services = ( 'dyndns1' => { @@ -685,6 +688,15 @@ my %services = ( $variables{'woima-service-common-defaults'}, ), }, + 'dondominio' => { + 'updateable' => undef, + 'update' => \&nic_dondominio_update, + 'examples' => \&nic_dondominio_examples, + 'variables' => merge( + $variables{'dondominio-common-defaults'}, + $variables{'service-common-defaults'}, + ), + }, ); $variables{'merged'} = merge($variables{'global-defaults'}, $variables{'service-common-defaults'}, @@ -4676,6 +4688,83 @@ sub nic_woima_update { } } +###################################################################### +## nic_dondominio_examples +###################################################################### +sub nic_dondominio_examples { + return < Date: Thu, 6 Jun 2019 19:37:51 +0800 Subject: [PATCH 5/8] Restore ability to update multiple namecheap domains (#64) * Revert to previous functionality * Revert example config * Remove redundant commas * Update example conf * Revert whitespace formatting --- ddclient | 16 +++++++++------- sample-etc_ddclient.conf | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ddclient b/ddclient index 5f65d95..09cc63a 100755 --- a/ddclient +++ b/ddclient @@ -3600,12 +3600,12 @@ Configuration variables applicable to the 'namecheap' protocol are: server=fqdn.of.service ## defaults to dynamicdns.park-your-domain.com login=service-login ## login name and password registered with the service password=service-password ## - hostname ## the hostname to update. + fully.qualified.host ## the hostname to update. Example ${program}.conf file entries: ## single host update - protocol=namecheap, \\ - login=my-namecheap.com-login, \\ + protocol=namecheap \\ + login=my-namecheap.com-login \\ password=my-namecheap.com-password \\ myhost @@ -3630,15 +3630,17 @@ sub nic_namecheap_update { ## update each configured host foreach my $h (@_) { - my $ip = delete $config{$h}{'wantip'}; + my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); verbose("UPDATE:","updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/update"; - my $domain = $config{$h}{'login'}; - $url .= "?host=$h"; - $url .= "&domain=$domain"; + my $domain = $config{$h}{'login'}; + my $host = $h; + $host =~ s/(.*)\.$domain(.*)/$1$2/; + $url .= "?host=$host"; + $url .= "&domain=$domain"; $url .= "&password=$config{$h}{'password'}"; $url .= "&ip="; $url .= $ip if $ip; diff --git a/sample-etc_ddclient.conf b/sample-etc_ddclient.conf index 30b0ca4..8630634 100644 --- a/sample-etc_ddclient.conf +++ b/sample-etc_ddclient.conf @@ -161,7 +161,7 @@ ssl=yes # use ssl-support. Works with # server=dynamicdns.park-your-domain.com, \ # login=my-namecheap.com-login, \ # password=my-namecheap.com-password \ -# myhost.namecheap.com +# fully.qualified.host ## ## From 4467c635271c9189f7ed8a234bb00dfd5172af3c Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 25 Jun 2019 14:16:37 -0400 Subject: [PATCH 6/8] update readme, document Data::Validate::IP --- README.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 055b3c3..4d35ee7 100644 --- a/README.md +++ b/README.md @@ -29,28 +29,29 @@ Dynamic DNS services currently supported include: Freemyip - See https://freemyip.com for details woima.fi - See https://woima.fi/ for details -DDclient now supports many of cable/dsl broadband routers. +DDclient now supports many of cable/dsl broadband routers. -Comments, suggestions and requests: use the forums on +Comments, suggestions and requests: use the forums on http://sourceforge.net/projects/ddclient/ -The code was originally written by Paul Burry and is now hosted and maintained +The code was originally written by Paul Burry and is now hosted and maintained through sourceforge.net. Please check out http://ddclient.sf.net ------------------------------------------------------------------------------- -REQUIREMENTS: +## REQUIREMENTS: - one or more accounts from one of the dynamic DNS services - Perl 5.014 or later - (you need the IO::Socket::SSL perl library for ssl-support, - JSON::PP perl library for JSON support and - IO::Socket:INET6 perl library for ipv6-support) + - `Data::Validate::IP` perl library + - `IO::Socket::SSL` perl library for ssl-support + - `JSON::PP` perl library for JSON support + - `IO::Socket:INET6` perl library for ipv6-support - Linux or probably any common Unix system ------------------------------------------------------------------------------- -INSTALLATION: +## INSTALLATION: cp ddclient /usr/sbin/ mkdir /etc/ddclient @@ -71,16 +72,16 @@ INSTALLATION: cp sample-etc_rc.d_init.d_ddclient.alpine /etc/init.d/ddclient ## enable automatic startup when booting rc-update add ddclient - ## make sure you have perl installed + ## make sure you have perl installed apk add perl ## start the first time by hand rc-service ddclient start - + ## For those using Ubuntu style rc files and using daemon-mode: cp sample-etc_rc.d_init.d_ddclient.ubuntu /etc/init.d/ddclient ## enable automatic startup when booting update-rc.d ddclient defaults - ## make sure you have perl installed + ## make sure you have perl installed apt-get install perl ## start the first time by hand service ddclient start @@ -89,7 +90,7 @@ INSTALLATION: ## as described below. ------------------------------------------------------------------------------- -TROUBLESHOOTING: +## TROUBLESHOOTING: 1. enable debugging and verbose messages. ``$ ddclient -daemon=0 -debug -verbose -noquiet`` @@ -109,10 +110,10 @@ TROUBLESHOOTING: ``fw=url-to-your-router``'s-status-page ``fw-skip=any-string-preceding-your-IP-address`` - ddclient does something like this to provide builtin support for + ddclient does something like this to provide builtin support for common routers. For example, the Linksys routers could have been added with: - + fw=192.168.1.1/Status.htm fw-skip=WAN.*?IP Address @@ -134,7 +135,7 @@ TROUBLESHOOTING: while some others accept anything. ------------------------------------------------------------------------------- -USING DDCLIENT WITH ppp +## USING DDCLIENT WITH ppp If you are using a ppp connection, you can easily update your DynDNS entry with each connection, with: @@ -146,7 +147,7 @@ Alternatively, you may just configure ddclient to operate as a daemon and monitor your ppp interface. ------------------------------------------------------------------------------- -USING DDCLIENT WITH cron +## USING DDCLIENT WITH cron If you have not configured ddclient to use daemon-mode, you'll need to configure cron to force an update once a month so that the dns entry will @@ -157,7 +158,7 @@ not become stale. vi /etc/cron.d/ddclient ------------------------------------------------------------------------------- -USING DDCLIENT WITH dhcpcd-1.3.17 +## USING DDCLIENT WITH dhcpcd-1.3.17 If you are using dhcpcd-1.3.17 or thereabouts, you can easily update your DynDNS entry automatically every time your lease is obtained @@ -171,19 +172,19 @@ In my case, it is named dhcpcd-eth0.exe and contains the lines: #!/bin/sh PATH=/usr/sbin:/root/bin:${PATH} logger -t dhcpcd IP address changed to $1 - ddclient -proxy fasthttp.sympatico.ca -wildcard -ip $1 | logger -t ddclient + ddclient -proxy fasthttp.sympatico.ca -wildcard -ip $1 | logger -t ddclient exit 0 Other DHCP clients may have another method of calling out to programs -for updating DNS entries. +for updating DNS entries. Alternatively, you may just configure ddclient to operate as a daemon and monitor your ethernet interface. ------------------------------------------------------------------------------- -USING DDCLIENT WITH dhclient +## USING DDCLIENT WITH dhclient -If you are using the ISC DHCP client (dhclient), you can update +If you are using the ISC DHCP client (dhclient), you can update your DynDNS entry automatically every time your lease is obtained or renewed by creating an executable file named: /etc/dhclient-exit-hooks From 27b42691b04573fdf17718215ba94df3dccef76c Mon Sep 17 00:00:00 2001 From: fabianskibr <47755037+fabianskibr@users.noreply.github.com> Date: Sat, 3 Aug 2019 14:57:27 -0300 Subject: [PATCH 7/8] add nsupdate.info config samples --- sample-etc_ddclient.conf | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sample-etc_ddclient.conf b/sample-etc_ddclient.conf index 8630634..63d8a65 100644 --- a/sample-etc_ddclient.conf +++ b/sample-etc_ddclient.conf @@ -240,3 +240,24 @@ ssl=yes # use ssl-support. Works with # login=your-myonlineportal-username # password=your-myonlineportal-password # domain.myonlineportal.net + +## +## nsupdate.info IPV4(https://www.nsupdate.info) +## +#protocol=dyndns2 +#use=web, web=http://ipv4.nsupdate.info/myip +#server=ipv4.nsupdate.info +#login=domain.nsupdate.info +#password='123' +#domain.nsupdate.info + +## +## nsupdate.info IPV6 (https://www.nsupdate.info) +## ddclient releases <= 3.8.1 do not support IPv6 +## +#protocol=dyndns2 +#usev6=if, if=eth0 +#server=ipv6.nsupdate.info +#login=domain.nsupdate.info +#password='123' +#domain.nsupdate.info From 8a4c93f59270ce890914ba775771b64aa984e104 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 29 Aug 2019 09:38:10 -0500 Subject: [PATCH 8/8] Stop putting a Content-Type into the request, if one is already present --- ddclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient b/ddclient index 2ebbc95..3df4aff 100755 --- a/ddclient +++ b/ddclient @@ -2034,7 +2034,7 @@ sub geturl { $request .= "Authorization: Basic $auth\n" if $login || $password; $request .= "User-Agent: ${program}/${version}\n"; if ($data) { - $request .= "Content-Type: application/x-www-form-urlencoded\n"; + $request .= "Content-Type: application/x-www-form-urlencoded\n" if ! $headers =~ /^Content-Type: /; $request .= "Content-Length: " . length($data) . "\n"; } $request .= "Connection: close\n";