Able to access web by ip, but not by dns name

I'd like to post a solution to a problem I've encountered in my university. The issue is closely related to this post. I asked the user whether or not he found a solution but he never responded. In addition, I'm not sure whether or not this solution is case-specific or general.

The situation

In one of my university's buildings, public wi-fi would work only with ip addresses, but not with domain names. For instance, I could ping 8.8.8.8 or go to google in firefox by 74.125.227.142 ip address, but ping google.com or accessing google.com in firefox would not work.

The solution

I will post solution to my problem bellow. Feel free to add other responses or other solutions for other users who may encounter similar issues.


Once I've encountered this issue, I've been researching it for a while, and figured out that this may be dns problem. By reading this post, I've learned that there is number of ways to add or supersede the DNS servers provided by your network, however none of the solutions seemed to work. As user brad mentioned, dns is still being controlled by dnsmasq.

Now, by poking around config files in /etc/ I found the /etc/NetworkManager/NetworkManager.conf file, which had the following information:

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

I've changed the dns line, and now the file reads like this:

[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq
dns=208.67.222.222

[ifupdown]
managed=false

After restarting Network Manager with sudo service network-manager restart everything started working properly, and the solution still works after rebooting. Note: 208.67.222.222 is OpenDNS public server.

What may have happened:

While on the network, the output of nm-tool was the following:

DNS:             4.2.2.2
DNS:             8.8.8.8
DNS:             164.47.7.10
DNS:             164.47.7.11

I believe, my uni has their own DNS server, which is 164.47.7.11 and .10, and dnsmasq queries the closest one, so my requests never even got to 8.8.8.8.

Hope this solutions helps to other users, and please let me know if my solution to this problem is valid, safe enough, or reasonable enough.

Concerning answering my own question:

I'm doing so to make this solution public and documented, at least for my particular case. Also I'd like to reference this post on meta.askubuntu.com.

Update:

Having returned home from uni today, I've discovered that I couldn't connect to my home wifi. I've read-up a little on man NetworkManager.conf and it turns out that dns= in [main] is actually a line for plug-ins, so line dns=dnsmasq is actually adding dnsmasq plugin to the network manager, apparently. So my solution still worked, just not as expected. Here'ss excerpt from the man page:

dns=plugin1,plugin2, ... List DNS plugin names separated by ','. DNS plugins are used to provide local caching nameserver functionality (which speeds up DNS queries) and to push DNS data to applications that use it.

So by setting dns=208.67.222.222 I may have, basically, prevented network manager from using that plug in, which would otherwise use local dns server (which apparently doesn't work).

Update #2:

What I've done so far is to comment out dnsmasq and ditch my internet service provider's DNS. Now, telling Network Manager is explained in this post, and it's a GUI method: simply open the Network Manager indicator, select "Edit Connections", open your network's name by pressing "Edit", and under IPv4 Settings tab, choose "Automatic (DHCP) addresses only ".

The very same thing can be done in command line , by editing a file for your specific connection stored in /etc/NetworkManager/system-connections. Bellow is the relevant portion of my connection file:

[ipv4]
method=auto
dns=208.67.222.222;
ignore-auto-dns=true

[ipv6]
method=auto

Now, with all these configurations (commented out dsnmaq plug-in from NetworkManager.conf and connection set to Automatic(DHCP) addresses only), I've basically achieved all that i was trying to get going all along - get my machine connect by domain names, and somehow get around using university's dns server, because that wone got me nowhere.

nm-tool confirms that I am using the DNS I wanted as well as dig google.com and /etc/resolv.conf.

This is the last update on this question/answer, and I don't plan adding anything else, but feel free to add any relevant information as a separate answer or in comments, as well as suggestions.

Hope this helps to other Ubuntu users, and Linux users in general !

``