It replaces the nameserver (DNS) used on your machine by the Google Public DNS service. If running that command helps you out, you're having DNS issues in the default settings provided by your network probably (DHCP). While it would be better to resolve the root cause of the issue, this is a general answer to your question.
Explanation of the command
sudo echo nameserver 184.108.40.206 > /etc/resolv.conf
sudo elevates privileges to be root in this case.
echo just outputs the arguments following to the standard output (in this case it outputs
> redirects standard output to a file (overwrites it) in a regular Unix shell.
/etc/resolv.conf is the file where the output is written to.
- Having a line
nameserver 220.127.116.11 in
/etc/resolv.conf makes the system using the nameserver having IP address
18.104.22.168 for resolving domain names to IP addresses. (very short version of what actually happens)
22.214.171.124 is one of the addresses published by Google as to where their public DNS services are listening on.
While this explanation sounds plausible, this won't work, because of an error you'll get:
bash: /etc/resolv.conf: Permission denied
Why? The output redirection is handled by your shell (here: Bash) and is not taken into account for the command used for
sudo. Similar to how multiplying in maths has precedence over adding. So, it's just
echo that has got elevated privileges, but your shell hasn't! To solve this, one should run this command like
sudo sh -c "echo nameserver 126.96.36.199 > /etc/resolv.conf"
or, by using a pipe and
tee to output it to a file:
echo nameserver 188.8.131.52 | sudo tee /etc/resolv.conf #prints to screen as well
Ubuntu and Network Manager
On Ubuntu this is only a temporary change, as Network Manager "manages" the
/etc/resolv.conf file. Local modifications will be overwritten. That's why you should configure this in Network Manager to have it persistent.
Configuration using Network Manager
I would recommend configuring your PC properly using Network Manager. I'm assuming you're using DHCP on your network here (most common). Then do this to perform the same as equivalent to the command you were using:
Open Edit connections:
Edit the connection profile you're using.
On the IPv4 Settings tab:
Method: Automatic (DHCP) addresses only
This setting makes it doing a regular DHCP request for IP address configuration of your host, but it will ignore other non-mandatory options like DNS servers suggested.
- DNS Servers:
- Hit Save
In a local or corporate network the local DNS server might be used for local hosts. You'll loose this functionality by directly asking Google's servers to resolve names for you. So, if for example the local DNS server would know what "printer" is, then you'll loose using your printer by that name.
So, please, fix your local DNS server instead. If it's just a simple forwarder to a broken DNS server of your ISP and you can't change that (ISP-managed all-in-one-router for example), then this
184.108.40.206 solution might be your only option.