ページ

2019-04-20

(Linux)journalctlから見つけたエラーを解消してみた

先日、jouranalctlコマンドの存在を知り、そこからディスク容量節約の技を発見したのですが、今度はjournalctlで記録されているログから見つけたエラーを1つ解消した、というお話です。




見つけたエラーは以下の通りです。

systemd-resolved[677]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
 
このエラーがけっこうな頻度で発生していることがわかりました。しかも連続して複数回記録されていて気になりました。(このエラーを解消すればログの出力量が減って、結果的にディスク容量がさらに節約できるのでは?という発想です)
エラーメッセージをキーワードに調べてみると、どうも海外でUbuntu 18.04を使用されている方でもどうようなエラーメッセージに困っているようでした。ワタシのPCはLinux Mint 19.1ですが、ベースがUbuntu 18.04なので合致するかもしれないと思い、解決策を試してみることにしました。
結論としては /etc/resolv.conf のシンボリックリンク先が間違っているので修正すれば解消するよ、ということでした。

$ ls -la /etc/resolv.conf 
 lrwxrwxrwx 1 root root 39 11月 12 21:22 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

現状はシンボリックリンク先が /run/systemd/resolve/stub-resolv.conf というファイルでした。

ファイルの中身を確認してみると以下の通りでした。

$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
 
nameserver 127.0.0.53
options edns0

/run/systemd/resolve/ 配下には stub-resolv.conf の他に resolv.conf というファイルもあり、こちらの中身も確認してみると以下の通りでした。

$ cat ./resolv.conf 
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 1.1.1.1
nameserver 8.8.8.8

なんとなく、stub-resolv.conf ではなくて resolv.conf の方がワタシがカスタマイズした内容が含まれているので正しそうです。

ということで、まずはシンボリックリンクを解除しました。

$ sudo unlink /etc/resolv.conf

続いて、正しいと思われるファイルにシンボリックリンクを張り直します。

$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

ls コマンドでシンボリックリンクが期待した通りに張られていることを確認してみました。

$ ls -al /etc/resolv.conf 
 lrwxrwxrwx 1 root root 32  4月 19 15:31 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

問題なさそうだったので、今度は cat コマンドでファイルの内容も確認してみました。


$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 1.1.1.1
nameserver 8.8.8.8

大丈夫そうです。resolved に反映させようと以下のコマンドを発行してみました。

$ sudo systemctl restart systemd-resolved.service

このコマンドでは反映されなかったようで、journalctl コマンドで確認してみてもまだエラーメッセージは解消していませんでした。そこで、最後はPCを再起動してみたところ、journalctl の結果からエラーメッセージが消えていることが確認できました。メデタシ、メデタシ。