Thank you for your help. I managed to solve my problem. My bad. Slapped my wrist.
nmcli dev list iface eth0
returns correct DNS information. My office's DNS is giving correct DNS and IP. What happened was the DNS server returned domain A (local office). However I was trying to connect to another site (domain B). Hence nslookup and ssh without the domain B supplied will return error.
Eg:
ssh hostname (Does not work)
ssh hostname.domainB.com (works)
This is because even though I am connected successfully to the network. I am with domain A. I figured out that I need to append my dns suffix in /etc/resolvconf/tail
to overcome this otherwise I need to specify domainB each time.
To add one more important observation. It took me a while to troubleshoot as nslookup and /etc/resolv.conf always points to 127.0.1.1. It confuses me as to why it goes to local DNS than my DNS server. I found it is the way Ubuntu Desktop uses resolvconf and local DNS and it is specified in /etc/NetworkManager/NetworkManager.conf (entry dns=dnsmasq)
.
Problem: In my case I accidentally removed the resolvconf
file. So my computer is connected to the internet, but it has no idea what a DNS server is and so it has no way of translating readable URLs into IP addresses. Hence you can do ping 8.8.8.8
and it will respond, but ping google.com
fails.
So the solution is basically to reinstall resolvconf
. You can download the package from the Ubunut archive: http://archive.ubuntu.com/ubuntu/pool/main/r/resolvconf
One neat hack around this is to go to another computer, or your phone, or whatever and find out the address of archive.ubuntu.com
- just ping it and copy the IP address. You could also use a WHOIS service I guess.
Then go back to the Ubuntu system and open /etc/hosts
and add:
x.x.x.x archive.ubuntu.com
where x.x.x.x
is the IP address you found out via ping on another machine. So now your computer should know about archive.ubuntu.com
. You can then open the page in a browser and navigate to the resolvconf
package. Of course putting in that IP address would also work and you should probably avoid leaving it in your hosts file in case it changes later.
Download the most recent package, and then run sudo dpkg -i resolvconf_1.79ubuntu8_all.deb
or whatever the deb
file you downloaded was. I suggest manually running dpkg even if your browser prompts you to install it, it didn't work that way for me.
Presto: you now have resolveconf again and it should work more or less instantly.
Best Answer
First, your /etc/systemd/resolved.conf should look like:
Then run:
sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
And check your systemd-resolved is enabled with:
systemctl status systemd-resolved.service
and if not then enable it:systemctl enable systemd-resolved.service
and start:systemctl start systemd-resolved.service
Seems, that's all.