How can I flush the DNS on Ubuntu 17.04?

I seem to have a few DNS issues at the moment since upgrading to 17.04 from 16.10 and went to flush the DNS but I can't find how to.

Can anyone tell me please?

UPDATE

I was having so many issues with DNS that I came across this article.

So I tried the mentioned changes and DNS seems to be behaving now.

tl;dr

$ sudo rm -f /etc/resolv.conf
$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
$ reboot
share|improve this question
1  
I ran into the same thing yesterday. This took care of my issue: superuser.com/a/1200745 – Clay Oster Apr 19 '17 at 14:01
    
Possible duplicate of How do I clear the DNS cache? – Chai T. Rex Apr 22 '17 at 0:50
up vote 25 down vote accepted

You may use this command: sudo systemd-resolve --flush-caches

To verify that flush was sucessfull, use: sudo systemd-resolve --statistics

Sample output:

Cache
  Current Cache Size: 0
          Cache Hits: 101
        Cache Misses: 256
share|improve this answer
    
This answer improves on the previous one so I have marked it as the one true answer. – dibs Apr 26 '17 at 21:54

This command should restart the local name service and flush the local DNS cache:

systemctl restart systemd-resolved.service

There is probably a way of getting it to just flush the cache instead of restart, but restart suited my purposes.

share|improve this answer
    
That seems to have fixed the issue. Thanks! – dibs Apr 23 '17 at 1:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.