You probably know that alphabetic web addresses like http://www.apple.com which humans remember better than IP addresses have to be translated into IP addresses such as 220.127.116.11 before your browser takes you to that website. This translation is extremely fast as to be almost unnoticeable.
ISPs offer their own DNS servers but there are several other companies that offer this service as well. I use OpenDNS which is a Cisco company. Their DNS servers are 18.104.22.168 and 22.214.171.124. This is a free service. If you change ISPs there is no need to change the DNS service.
On a Mac to change your DNS server, you go to System Preferences, Network. Unlock the padlock with your Mac password and then go to the DNS tab and press the + sign to add the above two DNS servers to your list. You can press the – sign to remove anything else if you choose too.
On an iOS or iPadOS device you can go to Settings, and then to WiFi and select the WiFI network. Click on the i beside the WiFi name and scroll down to DNS and change it from Automatic to Manual and add the above servers to the list and delete anything else if you choose to.
If you chose to you can do this at the router level and by referring to this webpage you can see how by referencing your particular router.