Can't ping websites with domains but can ping websites with ips

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:

Pinging 142.250.64.238 (Google's ip)

Also I now can't update my server since the packages use domains:

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
3

1 Answer

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`

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like