11

I am getting the following error from ubuntu 20.04 terminal, connected via wired ethernet connection: When I type the following command which I am using in a bash script:

ping -c 1 google.com

for a health check to ensure it has access, I get the following error:

ping: google.com: Temporary failure in name resolution

Some background

I overwrote my older gaming rig to be a ubuntu multi purpose server (including smart home automation) in my home network. It used to be windows 10, but I formatted the drive and installed ubuntu on it.

I have not yet been able to access the internet with ubuntu, however, I do know that the equipment works because I left the internet wired in, I actually downloaded ubuntu via that machine onto the usb before installing.

Now I cannot see or connect to the ubuntu server from other devices and cannot reach the internet to download even basic tools like netstat.

At this point, I feel like I've bashed my head against a wall and scoured the internet (and lots of other stack overflow threads) and tried a bunch of things that didn't work.

Any help would be greatly appreciated!

Edit: As requested in comments, I am attaching a screenshot, since I am not able access the computer via any network. Only via hdmi.

enter image description here

Edit 2: Second screenshot as requested.

enter image description here

7
  • 1
    Pease edit your question to show the result of these terminal commands: ip addr show and also: cat /etc/netplan/*.yaml
    – chili555
    Commented Aug 15, 2021 at 22:35
  • I don't have access to it, so i took a pic with my phone and just commented out some personal naming stuff
    – Zedd
    Commented Aug 15, 2021 at 22:43
  • 1
    One more, please: ls -al /etc/resolv.conf Thanks.
    – chili555
    Commented Aug 15, 2021 at 22:48
  • 1
    Is IPv6 enabled in Network Manager? Is this a static IP address you set in Network Manager? Is the reult the same if you do: ping4 -c1 www.google.com So far, everything looks fine.
    – chili555
    Commented Aug 15, 2021 at 23:11
  • 1
    Let us continue this discussion in chat.
    – chili555
    Commented Aug 15, 2021 at 23:17

4 Answers 4

17

It's likely your default DNS server is pointing to an IP address that is not capable of resolving DNS queries. You should check the DNS settings in the file that /etc/resolv.conf is pointing to. When you go to that file (/var/run/systemd/resolve/resolve.conf), look at the IP that is right next to the keyword namespace. You should set it to your router's IP address (which can be found with the command route -n. Look for the gateway column and take the one that's not 0.0.0.0) or you can also set it to a public DNS server such as 1.1.1.1, 8.8.8.8 etc.

EDIT: Please follow these instructions:

Execute sudo rm /etc/resolv.conf

Execute sudo touch /etc/resolv.conf

Edit the file with sudo nano /etc/resolv.conf

Add this line to the file: nameserver 1.1.1.1

Press ctrl + s to save and ctrl + x to exit

Restart the service:

sudo systemctl restart systemd-resolved.service

Then try to access the internet again. If it still doesn't work, reboot the system and try again. That should solve your problem.

11
  • 2
    "cat: /var/run/systemd/resolve/resolve.conf: No such file or directory"
    – chili555
    Commented Aug 16, 2021 at 1:41
  • 1
    route and nano are basic commands that are in every linux distributions. I guess I understand the problem now. If you're getting this error "cat: /var/run/systemd/resolve/resolve.conf: No such file or directory", then it means you dont have any DNS server configured for your OS at all. The file that is supposed to contain DNS settings is not even present. We can fix this if you follow my instructions. I'll include them in my answer in just a little bit since I have character limitation here. Check out the answer please. Commented Aug 16, 2021 at 15:52
  • 1
    I just saw your answer. I didnt know you'd solved the problem. Awsome work. But the problem was you didnt have and DNS config file. If you run into any problem like that again, you can try the steps I explained above Commented Aug 16, 2021 at 16:11
  • 1
    Thank you so much Muahammed! yeah it was weird, it didn't even have ifconfig installed, let alone route lol And I can't take credit for the awesome work, it was all @chili555
    – Zedd
    Commented Aug 16, 2021 at 18:19
  • 2
    You're welcome Zedd. Wow that must have been tough. I'm glad you solved it. Then thanks are for @chili555 Commented Aug 16, 2021 at 18:31
2

Firstly, I have to give a shout out to @chili555 for spending literally hours last night helping me troubleshoot.

After many hours of troubleshooting, the simplest answer was the solution. Something must have gone wrong during installation, because after a reinstall from the same usb flash drive, my computer is on the network and accessing the internet.

I still don't know the true cause, but my server is up and running.

Thanks @chili555!

1
  • Awesome! Glad it's working as expected.
    – chili555
    Commented Aug 16, 2021 at 20:00
2

This is what helped in my case:

Ubuntu is now using systemd-resolve, which is controlled by resolvectl.

I found that no nameservers were configured:

$ resolvectl dns
Global:
Link 2 (enp1s0):
Link 3 (wlp2s0):

So I added one:

$ resolvectl dns wlp2s0 8.8.8.8 8.8.4.4 1.1.1.1

and now DNS lookup works!

$ nslookup example.com
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   example.com
Address: 93.184.215.14
Name:   example.com
Address: 2606:2800:21f:cb07:6820:80da:af6b:8b2c
1

Adding to the discussion here, I had a similar issue with my Xubutu 22.10 + gnome today.

In the past, recreating resolv.conf had helped me for a similar issue, but today it did not.

Ultimately I realised that I had a VPN client (windscribe) installed that I had switched off recently. As soon as I used the .Deb file to uninstall the package, my internet came back.

I'm leaving this resolution here for others who might have a similar issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .