Your iPhone or iPad normally uses the DNS servers provided by whatever Wi-Fi network you use. But you can set a custom DNS server and use Google Public DNS, OpenDNS, or any other DNS server you prefer.

Related: What Is DNS, and Should I Use Another DNS Server?

Each Wi-FI network you connect to has its own separate DNS server setting. If you want to use your custom DNS server on several different Wi-Fi networks, you'll have to change this setting once for each Wi-Fi network.

Open the Settings app and tap "Wi-Fi" to get started.

On the Wi-Fi screen, tap the information button (that's the "i" in a circle) to the right of the network you want to configure. To change the current Wi-Fi network's settings, tap the "i" button next to the Wi-Fi network you're currently connected to at the top of the screen.

Scroll down on the information screen and tap the "Configure DNS" option in the "DNS" section.

Next, tap the "Manual" option at the top of the screen, and then tap the red minus sign icons to the left of the automatically configured DNS servers to remove them from the list.

Tap the "Add Server" button, and then type the IP address of each DNS server you want to use on its own line. For example, add the primary DNS server on the first line and the secondary on the second line.

Tap "Save" when you're done. Remember, you'll need to repeat this process for every Wi-Fi network on which you want to use a custom DNS server.

Related: How to Forget a Wi-Fi Network on Your iPhone or iPad

Your iPhone or iPad remembers this setting, even after you disconnect from and reconnect to the network. However, if you have iOS forget the network, you'll have to set it up from scratch again. And, if you ever want to undo this change, just return to the above screen, tap the "Automatic" option, and tap "Save". Your iPhone or iPad will revert to the default DNS settings for that network.

If your current DNS server just isn't working well and you want something better, Google Public DNS (IP addresses 8.8.8.8 and 8.8.4.4) and OpenDNS (IP addresses 208.67.222.222 and 208.67.220.220) are some commonly recommended DNS servers we like.

Related: The Best DNS Servers for Secure Browsing

You can also change the DNS server for all devices on your network by changing the DNS server on your router. Before you change the DNS server separately for each device on your home network, consider just changing it once on your router instead.