{"id":49,"date":"2014-12-20T19:29:00","date_gmt":"2014-12-20T10:29:00","guid":{"rendered":"http:\/\/yokensaka.com\/centos\/?p=49"},"modified":"2014-12-20T19:29:57","modified_gmt":"2014-12-20T10:29:57","slug":"ip%e3%82%a2%e3%83%89%e3%83%ac%e3%82%b9%e8%87%aa%e5%8b%95%e6%9b%b4%e6%96%b0ddnsddo-jp","status":"publish","type":"post","link":"http:\/\/yokensaka.com\/centos\/?p=49","title":{"rendered":"IP\u30a2\u30c9\u30ec\u30b9\u81ea\u52d5\u66f4\u65b0DDNS(ddo.jp)"},"content":{"rendered":"<p>\u4eca\u4f7f\u3063\u3066\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3067DDNS\u306e\u81ea\u52d5\u66f4\u65b0\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3053\u3068\u3082\u3042\u308a\u3001\u305f\u3073\u305f\u3073\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u81ea\u52d5\u66f4\u65b0\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u898b\u76f4\u3059\u3053\u3068\u306b\u3002\u3053\u306e\u30b5\u30a4\u30c8\u306fddo.jp\u306eDDNS\u3092\u4f7f\u3063\u3066\u308b\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u8abf\u3079\u3066\u898b\u305f\u3089\u3001<a href=\"http:\/\/greenbeens.blog85.fc2.com\/blog-entry-3.html\" target=\"_blank\">\u3053\u3061\u3089\u306e\u30b5\u30a4\u30c8<\/a>\u3067\u7d39\u4ecb\u3055\u308c\u3066\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u4f7f\u308f\u305b\u3066\u3082\u3089\u3046\u3053\u3068\u306b\u3057\u305f\u3002<br \/>\n\u81ea\u52d5\u66f4\u65b0\u306e\u52d5\u304d\u3068\u3057\u3066\u306f<br \/>\n\u3000\u3000(1)ddo.jp\u30b5\u30a4\u30c8\u3067\u7528\u610f\u3057\u3066\u3044\u308b\u30ea\u30e2\u30fc\u30c8IP\u78ba\u8a8d\u30b5\u30a4\u30c8\u3067\u73fe\u5728\u306eIP\u3092\u78ba\u8a8d\u3002<br \/>\n\u3000\u3000(2)\u524d\u56de\u66f4\u65b0\u6642\u306eIP\u3068\u5909\u66f4\u6642\u9593\u3092\u30c6\u30f3\u30dd\u30e9\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3002<br \/>\n\u3000\u3000(3)\u524d\u56de\u66f4\u65b0\u6642\u3068IP\u540c\u3058\u3067\u3001\u304b\u3064\u524d\u56de\u66f4\u65b0\u6642\u304b\u30891\u9031\u9593\u4ee5\u4e0a\u7d4c\u3063\u3066\u306a\u304b\u3063\u305f\u3089\u7d42\u4e86\u3002<br \/>\n\u3000\u3000(4)\u305d\u3046\u3067\u306a\u304b\u3063\u305f\u3089\u3001DDNS\u3092\u66f4\u65b0\u3002\u5909\u66f4\u5185\u5bb9\u3092\u30c6\u30f3\u30dd\u30e9\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u3068\u30ed\u30b0\u306b\u66f8\u304d\u8fbc\u3080\u3002<br \/>\n\u3068\u3044\u3046\u611f\u3058\u3067\u81ea\u52d5\u66f4\u65b0\u3055\u308c\u308b\u3068\u306e\u3053\u3068\u3002\u3042\u3068\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001lynx\u304c\u4f7f\u3048\u308b\u3053\u3068\u304c\u524d\u63d0\u3068\u306a\u3063\u3066\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u307e\u305alynx\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u306b\u3059\u308b\u3002<br \/>\n<b>\u25a0\u3000lynx\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/b><\/p>\n<pre>\r\n[root@server ~]# yum -y install lynx\r\n<\/pre>\n<p><b>\u25a0\u3000\u81ea\u52d5\u66f4\u65b0\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4f5c\u6210<\/b><\/p>\n<pre>\r\n[root@server1 ~]# cd \/usr\u3000\u2190\u3000\/usr \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u79fb\u52d5\r\n[root@server1 usr]# mkdir -p ddns\u3000\u2190\u3000ddns \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210\r\n[root@server1 usr]# cd ddns\u3000\u2190\u3000ddns \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u79fb\u52d5\r\n[root@server1 ddns]# vi ddo.jpIP_upgrade.pl\u3000\u2190\u3000\u81ea\u52d5\u66f4\u65b0\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4f5c\u6210\r\n#!\/usr\/bin\/perl\r\n#\r\n# Check ip address, and update DDNS for \"ddo.jp\"\r\n#\r\n#\r\n# parameters\r\n# \"ddo.jp\" ID &amp; PASSWD\r\nlocal $ID     = '\u30c9\u30e1\u30a4\u30f3'; # Login ID(It serves as a domain name)\r\nlocal $PASSWD = '\u30d1\u30b9\u30ef\u30fc\u30c9'; # Login password\r\n# file names\r\nlocal $CRT_IPF = '\/tmp\/CRT_IP2.dat';\r\nlocal $LOG     = '\/var\/log\/ddns.log';\r\n# Check current ip address on the appointed URL web page.\r\nlocal $CHK_URL=\"http:\/\/info.ddo.jp\/remote_addr.php\";\r\n#\r\nlocal $INTERVAL = 604800;       # 1 weeks\r\n#\r\n$ENV{'PATH'}=\"\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/local\/bin\";\r\n#---------------------------------------------------\r\n# main\r\nmy ($NEW_IP,$CRT_IP,$CRT_TIME,$i);\r\n# get current ip address which set as the domain.\r\n$CRT_IP   = \"\";\r\n$CRT_TIME = \"0\";\r\nopen(INPUT, $CRT_IPF);\r\nforeach(&lt;INPUT&gt;){\r\nchop;\r\n\/^IP:\/   &amp;&amp; do{ $CRT_IP   = $' };\r\n\/^TIME:\/ &amp;&amp; do{ $CRT_TIME = $' };\r\n}\r\nclose(INPUT);\r\n# check a assigned ip address\r\nopen(INPUT, \"lynx -dump \\\"$CHK_URL\\\" | \");\r\nforeach(&lt;INPUT&gt;){\r\n\/([0-9\\.].*)\/ &amp;&amp; do{ $NEW_IP = $1};\r\n}\r\nclose(INPUT);\r\n# Lapsed time from the last update\r\n$i = time() - $CRT_TIME;\r\n# change DDNS, supposing the IP address is changed.\r\nif ( ( ($NEW_IP ne \"\" )&amp;&amp;($CRT_IP ne $NEW_IP) ) || ( $i &gt; $INTERVAL) ) {\r\n# change DDNS\r\nopen(INPUT2,\r\n\"lynx -dump \\\"http:\/\/ddo.jp\/dnsupdate.php?dn=$ID&amp;ip=$NEW_IP&amp;pw=$PASSWD\\\" |\");\r\n# check whether change of DDNS has been successful\r\nforeach(&lt;INPUT2&gt;){\r\n\/SUCCESS: \/ &amp;&amp; do{ $TEMP = 1;};\r\n}\r\nif( $TEMP == 1){\r\n# save a new IP address.\r\n$i = time();\r\nopen (OUTPUT ,\"&gt;$CRT_IPF\");\r\nprint OUTPUT \"IP:$NEW_IP\\nTIME:$i\\n\";\r\nclose OUTPUT;\r\n# write a message on the log file\r\n$time = conv_date(time());\r\nopen(LOG, \"&gt;&gt; $LOG\");\r\nprint(LOG $time . \":change \\\"\" .\r\n$ID . \".ddo.jp\\\" &lt;= \" . $NEW_IP . \"\\n\");\r\nclose(LOG);\r\n}\r\n}\r\nsub conv_date{\r\nmy ($times,$mode) = @_;\r\nmy ($sec,$min,$hour,$mday,$month,$year,$wday);\r\n($sec,$min,$hour,$mday,$month,$year,$wday,undef,undef) = localtime($times);\r\n$month++;\r\n$year += 1900;\r\n$times = sprintf(\"%d\/%02d\/%02d %02d:%02d\", $year, $month, $mday,\r\n$hour, $min);\r\nreturn($times);\r\n}\r\n<\/pre>\n<p><b>\u25a0\u3000\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5b9f\u884c\u6a29\u9650\u3092\u4e0e\u3048\u308b<\/b><\/p>\n<pre>\r\n[root@server1 ddns]# chmod +x ddo.jpIP_upgrade.pl\r\n<\/pre>\n<p><b>\u25a0\u3000\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u6bce\u66422\u5206\u30015\u5206\u30018\u5206\u30683\u5206\u304a\u304d\u306b\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b \/etc\/cron.d\/ \u306b\u8ffd\u52a0\u3002<\/b>\u203b\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306e\u307f<\/p>\n<pre>\r\n[root@server1 ~]# echo \"2-59\/3 * * * * root \/usr\/ddns\/ddo.jpIP_upgrade.pl\" > \/etc\/cron.d\/ddns\r\n<\/pre>\n<p><b>\u25a0\u30c6\u30f3\u30dd\u30e9\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u3068\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/b><\/p>\n<pre>\r\n[root@server1 ~]# echo -n \"\" > \/tmp\/CRT_IP2.dat\r\n[root@server1 ~]# echo -n \"\" > \/var\/log\/ddns.log\r\n<\/pre>\n<p><b>\u25a0\u3000\u505c\u96fb\u306a\u3069\u3067\u518d\u8d77\u52d5\u3055\u305b\u305f\u3068\u304d\u81ea\u52d5\u3067\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a<\/b>\u203b\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306e\u307f<\/p>\n<pre>\r\n[root@server1 ~]# vi \/etc\/rc.local\u3000\u2190\u3000\u30b7\u30b9\u30c6\u30e0\u8d77\u52d5\u6642\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u7de8\u96c6\r\n\u4ee5\u4e0b\u3092\u6700\u7d42\u884c\u3078\u8ffd\u52a0\r\nchmod +x \/usr\/ddns\/ddo.jpIP_upgrade.pl\r\n\/usr\/ddns\/ddo.jpIP_upgrade.pl\r\n<\/pre>\n<div align=right><a href=\"#\">\u25b2 \u30da\u30fc\u30b8\u30c8\u30c3\u30d7\u3078<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u4f7f\u3063\u3066\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3067DDNS\u306e\u81ea\u52d5\u66f4\u65b0\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3053\u3068\u3082\u3042\u308a\u3001\u305f\u3073\u305f\u3073\u30a2\u30af &hellip; <a href=\"http:\/\/yokensaka.com\/centos\/?p=49\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-ipddns"],"_links":{"self":[{"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=49"}],"version-history":[{"count":4,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":293,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions\/293"}],"wp:attachment":[{"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yokensaka.com\/centos\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}