First, I would recommend you try and determine where DNS is failing. It may be that it is local to your machine, or an issue at your router, or even that your ISP (this is assuming you rely on your ISP to provide DNS results).
So, when this happens, open up a command prompt and use nslookup to check your DNS.
Type 'nslookup' and you will go to an interactive prompt. By default, it will check A records, so type in something that you would expect to return such as 'google.com' and press enter. When it works, it will return the A records for google.com, so you should see the IP addresses for the domain. When it does not work, it will tell you it timed out, or that no record was returned.
Either way, it should first tell you the server that responded, this will let you know where it is trying to get its result.
So now you can use nslookup to change where you query. To do so you type in 'server IP-Address'. So for example, I often change to the following public DNS server to test 'server 220.127.116.11' (press enter to set). Then once again type in 'google.com' and press enter.
If this succeeds, then you know that it is the default DNS location that you normally query that is causing the issue. Here you have some options, you can usually change your router to point to the DNS server of your choice. It tends to default to your ISP... but maybe there is a better IP at your ISP to use, or you would like to use a public DNS, etc. Naturally you want to only use reputable DNS servers, as a compromised DNS server could provide you with altered records which would mean when you go to a site, you may actually be accessing a faked site (and providing login credentials to the wrong site for example).
You could also manually specify your own DNS server per computer (within the TCP/IP settings for your network connection).
The above is just the 'basic' most common explanation, there could be various other issues that can come to play. But start with using nslookup (on Windows machines, the tool 'dig' is the equivalent in Linux) to try and find the cause.