# [Ubuntu Tip] Change DNS settings in Ubuntu

You may need to change your [DNS](https://en.wikipedia.org/wiki/Domain_Name_System) settings in Ubuntu for various reason like faster internet or streaming media or safe browsing.

Here is a simple working method you can use, using [DNSmasq](https://packages.debian.org/sid/dnsmasq).

**1- Install DNSmasq:**


```
sudo apt-get install dnsmasq
```


**2- Edit DNSmasq Configure file:**


```
sudo gedit /etc/dnsmasq.conf
```


**3- Add your preferred DNS at the end of the file:**

_in this example I used Google DNS_


```
server=8.8.8.8
server=8.8.4.4
```


**4- Add system hosts file to Network Manager DNSmasq Config:**

**5- Restart DNSmasq and Network Manager:**


```
sudo service network-manager restart
```




## Flush the DNS Records

Previous methods is enough, but you may need to flush the DNS records in the browser you are using if you had any network problem after changing the DNS.

Here how to flush the DNS in Chrome and Chrome based browser like Opera and Vivaldi.

**1- Open DNS Settings page in chrome:**

_chrome://net-internals/#dns_

**2- Clear Host Cache:**

![](https://miro.medium.com/max/1338/1*KkpPuyFjRFtD0oceYQrafg.jpeg)

**3- Flush Socket Pools**

![](https://miro.medium.com/max/1128/1*Xxa17KypZNgID09E54nudw.jpeg)


* * *

## Best DNS servers

Here three best DNS servers you may want to use.

**1- Google DNS:** [ [Support](https://developers.google.com/speed/public-dns/docs/using?hl=en) ]


```
8.8.8.8
8.8.4.4
```


**2- OpenDNS:** [ [Support](https://use.opendns.com) ]


```
208.67.222.222
208.67.220.220
```


**3- Tunlr:** [ [Support](http://support.tunlr.com/) ]


```
45.33.81.76
45.33.12.13
```


* * *

## Test your system to check if its using the preferred DNS:

**_Ubuntu 15.04 and Above_**

Apply this command in the terminal:


```
nmcli dev show | grep DNS | sed 's/\s\s*/\t/g' | cut -f 2</span>
```


**_Ubuntu 14.04_**

*   Install [nm-tool](http://linux.die.net/man/1/nm-tool):


```
sudo apt-get install nm-tool
```


*   Then Apply this cmd:


```
nm-tool | grep DNS
```
---

%[https://medium.com/@foxoman/change-dns-settings-in-ubuntu-bcf535379dac]

---
[![bymecoffe.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1587235304131/Je4ZlrqY6.png)](https://www.buymeacoffee.com/foxoman)
 ***Thank you for your support!***


