DNSをIPフォワーディングを有効化しているマシンのIPで設定したいが名前解決できない

実現したいこと

DNSをあるマシンのIPに設定したうえで名前解決できるようにしたいです。
よろしくお願いします。

前提

ubuntu仮想マシンを2台動作させています。フォワーディングするマシンをA(172.16.30.137/24), それを利用してネットに接続させたいマシンをB(172.16.30.138/24)とします。
マシンAでは/stc/sysctl.confのnet.ipv4.ip_forward=1のコメントを外すことでフォワーディングを有効化しました。
マシンBではゲートウェイとDNSにマシンAのIPを設定しました。
マシンAをDNSとして動作させるために、bind9 bind9utilsをインストールし/etc/bindにあるnamed.conf.optionsに以下のように内容を追加しました。

// 追加: access control listの定義 acl internal-network { 172.16.30.0/24; }; options { directory "/var/cache/bind"; // If there is a firewall between you and nameservers you want // to talk to, you may need to fix the firewall to allow multiple // ports to talk. See http://www.kb.cert.org/vuls/id/800113 // If your ISP provided one or more IP addresses for stable // nameservers, you probably want to use them as forwarders. // Uncomment the following block, and insert the addresses replacing // the all-0's placeholder. // 追加: フォワーディング先をgoogle public dnsに指定 forwarders { 8.8.8.8; }; // 追加: 問い合わせを受け付けるネットワークおよびホスト allow-query { localhost; internal-network; }; // 追加: 再起問い合わせを許可(キャッシュDNSサーバ(リゾルバ)として動作させる) recursion yes; //======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== dnssec-validation auto; listen-on-v6 { any; }; };

マシンBの/etc/systemd/resolved.confは以下のように修正しました。

-コメント部分は長いので省略- [Resolve] # Some examples of DNS servers which may be used for DNS= and FallbackDNS=: # Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com # Google: 8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google # Quad9: 9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net # 修正箇所: DNS=をDNS=172.16.30.137にしました DNS=172.16.30.137 #FallbackDNS= #Domains= #DNSSEC=no #DNSOverTLS=no #MulticastDNS=no #LLMNR=no #Cache=no-negative #CacheFromLocalhost=no #DNSStubListener=yes #DNSStubListenerExtra= #ReadEtcHosts=yes #ResolveUnicastSingleLabel=no

マシンBの/run/systemd/resolve/resolv.confは以下のようになっています。

-コメント部分は長いので省略- nameserver 172.16.30.137 nameserver 172.16.30.137 search .

発生している問題・エラーメッセージ

マシンBにおいてdig www.youtube.comを例として実行すると以下のような出力が返ります。

$ dig www.youtube.com ;; communications error to 127.0.0.53#53: timed out

pingは以下のような出力となります。

$ ping www.youtube.com ping: www.youtube.com: Temporary failure in name resolution

マシンBにおける名前解決がこのようにできなくなっています。

試したこと

マシンAで同様にdigを行い得られたIPを設定してpingやtracerouteすると正常に到達できます。

ping 142.250.207.14 PING 142.250.207.14 (142.250.207.14) 56(84) bytes of data. From 172.16.30.137 icmp_seq=1 Redirect Host(New nexthop: 172.16.30.2) 64 bytes from 142.250.207.14: icmp_seq=1 ttl=128 time=12.4 ms From 172.16.30.137 icmp_seq=2 Redirect Host(New nexthop: 172.16.30.2) 64 bytes from 142.250.207.14: icmp_seq=2 ttl=128 time=13.5 ms From 172.16.30.137 icmp_seq=3 Redirect Host(New nexthop: 172.16.30.2) 64 bytes from 142.250.207.14: icmp_seq=3 ttl=128 time=13.9 ms ^C --- 142.250.207.14 ping statistics --- 3 packets transmitted, 3 received, +3 errors, 0% packet loss, time 2004ms rtt min/avg/max/mdev = 12.418/13.296/13.927/0.640 ms

マシンAでのresolvectl statusの実行結果です。

$ resolvectl status Global Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Current DNS Server: 8.8.8.8 DNS Servers: 8.8.8.8 Link 2 (ens33) Current Scopes: DNS Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 172.16.30.2 DNS Servers: 172.16.30.2 DNS Domain: localdomain

マシンBでのresolvectl statusの実行結果です。

$ resolvectl status Global Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Current DNS Server: 172.16.30.137 DNS Servers: 172.16.30.137 Link 2 (ens33) Current Scopes: DNS Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 172.16.30.137 DNS Servers: 172.16.30.137

補足情報(FW/ツールのバージョンなど)

vmware fusionをmac os上で動かしています。
マシンAのbindツールについてはこのサイトを参考にしました。
https://tryota.hatenablog.com/entry/2021/02/06/Ubuntu_server_DNSサーバの構築

コメントを投稿

0 コメント