1

The DNS on my Ubuntu Server isn't working. I changed some settings while trying to get my domain to go to my server and I think I reverted the changed back but it still doesn't work. It started happening after I removed Webmin by doing:

apt remove webmin

I know the problem is with dns since:

Pinging Google.com: https://i.stack.imgur.com/t9Uto.png

Pinging 142.250.64.238 (Google's ip) https://i.stack.imgur.com/RCcOo.png

Also I now can't update my server since the packages use domains: https://i.stack.imgur.com/89grR.png

This is what shows up when I do the command ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether a0:8c:fd:4a:1b:0e brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.13/24 brd 192.168.0.255 scope global dynamic enp1s0
       valid_lft 83038sec preferred_lft 83038sec
    inet6 2600:8802:2901:8a00:a28c:fdff:fe4a:1b0e/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 86384sec preferred_lft 86384sec
    inet6 fe80::a28c:fdff:fe4a:1b0e/64 scope link
       valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 68:14:01:51:32:10 brd ff:ff:ff:ff:ff:ff
  • Is this Ubuntu Server or Ubuntu Desktop? Which version? Have you checked to see if DNS servers are defined for the network? sudo ip a should provide this info. –  Jan 24 '21 at 00:50
  • It's Ubuntu Server 20.04.1 and when I do sudo ip a it says unable to resolve host server.bettermc.online: Name or service not known (Which is the domain I was trying to set up). It also shows the network info for enp1s0, lo wlo1 – SlashSlahStack Jan 24 '21 at 00:55
  • Can you update your question to include the output of ip a? This may make it easier for people to provide specific solutions. –  Jan 24 '21 at 00:58

1 Answers1

-1

try this flow:

remove the symlink:

sudo rm /etc/resolv.conf

in /etc/resolv.conf

sudo nano /etc/resolv.conf          

put

nameserver 8.8.8.8 
nameserver 8.8.4.4

and make it immutable:

sudo chattr +i /etc/resolv.conf    

The last command will add immutable bit, so the file doesn't get overwritten. After you set immutable bit, even the root account will not be able to write to the file. If you wish to edit the file again latter on, and remove immutable bit, use this command:

sudo chattr -i /etc/resolv.conf

No write permissions on a file even with `sudo`

user216
  • 100
  • You shouldn't do this unless you know what you're doing. This will break SystemD's resolve system, which is the new system in 18.04+ for local system resolution. – Thomas Ward Feb 05 '21 at 16:43