{"id":1389,"date":"2024-11-06T22:49:42","date_gmt":"2024-11-06T13:49:42","guid":{"rendered":"https:\/\/darkgray.homelinux.com\/blog\/?p=1389"},"modified":"2024-11-07T00:56:12","modified_gmt":"2024-11-06T15:56:12","slug":"net_dns2%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82","status":"publish","type":"post","link":"https:\/\/darkgray.homelinux.com\/blog\/?p=1389","title":{"rendered":"Net_DNS2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002"},"content":{"rendered":"\n<p>\u81ea\u5206\u306e\u30b5\u30a4\u30c8\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u306aip\u30a2\u30c9\u30ec\u30b9\u3092\u5f15\u304d\u305f\u304f\u3066\u8272\u3005\u8abf\u3079\u3066\u307f\u305f\u3002\u3067\u3000Net_DNS2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308c\u3070\u51fa\u6765\u305d\u3046\u3060\u3068\u5206\u304b\u3063\u305f\u306e\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"[]$ sudo dnf install php-pear\n[]$ sudo pear install Net_DNS2\n[]$ sudo systemctl restart php-fpm   #\u5ff5\u306e\u305f\u3081\u30ea\u30b9\u30bf\u30fc\u30c8\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">[]$ sudo dnf install php<\/span><span style=\"color: #F286C4\">-<\/span><span style=\"color: #F6F6F4\">pear<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">[]$ sudo pear install Net_DNS2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">[]$ sudo systemctl restart php<\/span><span style=\"color: #F286C4\">-<\/span><span style=\"color: #F6F6F4\">fpm   #\u5ff5\u306e\u305f\u3081\u30ea\u30b9\u30bf\u30fc\u30c8<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u8272\u3005\u306a\u30b5\u30a4\u30c8\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u30c6\u30b9\u30c8\u3057\u3066\u307f\u305f\u3002\u3000\u6ce8\u610f\u70b9\u306f\u3000\uff12\u884c\u76ee\u3067Net_DNS2.php\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u4e8b\u3002\u3053\u308c\u304c\u7121\u3044\u3068\u52d5\u304b\u306a\u3044\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\nrequire_once 'Net\/DNS2.php';\n\n$r = new Net_DNS2_Resolver(array('nameservers' =&gt; array('8.8.8.8')));\n\ntry\n{\n    $result = $r-&gt;query('darkgray.homelinux.com', 'A');\n\n    foreach($result-&gt;answer as $record)\n    {\n        echo $record-&gt;address, &quot;\\n&quot;;\n    }\n\n} catch(Net_DNS2_Exception $e)\n{\n    echo &quot;::query() failed: &quot;, $e-&gt;getMessage(), &quot;\\n&quot;;\n}\n?&gt;\n\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">&lt;?<\/span><span style=\"color: #F6F6F4\">php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">require_once <\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">Net\/DNS2.php<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">$r <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #F286C4; font-weight: bold\">new<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #62E884\">Net_DNS2_Resolver<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #62E884\">array<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">nameservers<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #F286C4\">=&gt;<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #62E884\">array<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">8.8.8.8<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">)));<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">try<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    $result <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> $r<\/span><span style=\"color: #F286C4\">-&gt;<\/span><span style=\"color: #62E884\">query<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">darkgray.homelinux.com<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">, <\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">A<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    <\/span><span style=\"color: #62E884\">foreach<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #FFB86C; font-style: italic\">$result<\/span><span style=\"color: #F6F6F4\">-&gt;<\/span><span style=\"color: #FFB86C; font-style: italic\">answer<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #FFB86C; font-style: italic\">as<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #FFB86C; font-style: italic\">$record<\/span><span style=\"color: #F6F6F4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">        echo $record<\/span><span style=\"color: #F286C4\">-&gt;<\/span><span style=\"color: #F6F6F4\">address, <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F286C4\">\\n<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">} <\/span><span style=\"color: #62E884\">catch<\/span><span style=\"color: #F6F6F4\">(Net_DNS2_Exception $e)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">    echo <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #E7EE98\">::query() failed: <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">, $e-&gt;<\/span><span style=\"color: #62E884\">getMessage<\/span><span style=\"color: #F6F6F4\">(), <\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F286C4\">\\n<\/span><span style=\"color: #DEE492\">&quot;<\/span><span style=\"color: #F6F6F4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3067\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u306e\u5b9f\u884c\u7d50\u679c\u306f\u30fb\u30fb\u30fb<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"[]$ php ip_test.php\n114.190.11\u30fb\u30fb\u30fb\" style=\"color:#f6f6f4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F6F6F4\">[]$ php ip_test.php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BF9EEE\">114.190<\/span><span style=\"color: #F6F6F4\">.<\/span><span style=\"color: #BF9EEE\">11<\/span><span style=\"color: #F6F6F4\">\u30fb\u30fb\u30fb<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u7121\u4e8b\u306b\u30b0\u30ed\u30fc\u30d0\u30ebip\u30a2\u30c9\u30ec\u30b9\u304c\u5f15\u3051\u305f\u3002\u3081\u3067\u305f\u3057\u3081\u3067\u305f\u3057<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5206\u306e\u30b5\u30a4\u30c8\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u306aip\u30a2\u30c9\u30ec\u30b9\u3092\u5f15\u304d\u305f\u304f\u3066\u8272\u3005\u8abf\u3079\u3066\u307f\u305f\u3002\u3067\u3000Net_DNS2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308c\u3070\u51fa\u6765\u305d\u3046\u3060\u3068\u5206\u304b\u3063\u305f\u306e\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002 \u8272\u3005\u306a\u30b5\u30a4\u30c8\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b5\u30f3\u30d7 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/darkgray.homelinux.com\/blog\/?p=1389\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Net_DNS2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":1279,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[81],"tags":[109],"class_list":["post-1389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-net_dns2"],"_links":{"self":[{"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1389"}],"version-history":[{"count":2,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1389\/revisions"}],"predecessor-version":[{"id":1391,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1389\/revisions\/1391"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/1279"}],"wp:attachment":[{"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/darkgray.homelinux.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}