在Ubuntu 16.04/18.04上如何刷新DNS缓存

查看当前DNS缓存大小:

sudo systemd-resolve --statistics

输出示例:

DNSSEC supported by current servers: no
Transactions
Current Transactions: 0
  Total Transactions: 30
Cache
  Current Cache Size: 14
          Cache Hits: 16
        Cache Misses: 14
DNSSEC Verdicts
              Secure: 0
            Insecure: 0
               Bogus: 0
       Indeterminate: 0

刷新Ubuntu DNS缓存

运行以下命令即可清除或者刷新缓存。

sudo systemd-resolve --flush-caches

如果上述命令没有刷新DNS缓存,则还可以使用以下命令。

sudo /etc/init.d/dns-clean restart
sudo /etc/init.d/networking force-reload
日期:2020-07-07 20:55:20 来源:oir作者:oir