OVH Guides

Changing an instance’s DNS servers

Find out how to change the default DNS servers on a Public Cloud instance

Last updated 02nd January 2020

Objective

The default DNS server configured on instances will be the OVHcloud server ( 213.186.33.99 ). You can change this, or add another DNS server. However, the DNS servers are configured automatically with a DHCP server, and you will not be able to change it by editing the resolv.conf file.

This guide explains the procedure to follow in order to change your instance’s DHCP configuration. You can then change your instance’s DNS servers.

Requirements

  • a Public Cloud instance

Instructions

For Debian/Ubuntu

You can read the resolv.conf file to check which DNS server is configured:

cat /etc/resolv.conf

domain openstacklocal search openstacklocal nameserver 213.186.33.99

  • Edit the /etc/dhcp/dhclient.conf file with the DNS servers you want. There are two ways of configuring this:

You can add a DNS server in addition to the one we provide by default.

supersede domain-name-servers 127.0.0.1;

You can add a DNS server to replace the one we provide by default.

prepend domain-name-servers 127.0.0.1;
  • Check that the configuration has been applied properly (this may take several minutes):
cat /etc/resolv.conf

domain openstacklocal
search openstacklocal
nameserver 127.0.0.1
nameserver 213.186.33.99

For CentOS/Fedora

nmcli

eth0: connected to System eth0
        "Red Hat Virtio"
        ethernet (virtio_net), FA:16:3E:B6:FB:89, hw, mtu 1500
        ip4 default
        inet4 51.77.205.51/32
        route4 0.0.0.0/0
        route4 51.77.205.51/32
        route4 51.77.204.1/32
        inet6 fe80::f816:3eff:feb6:fb89/64
        route6 ff00::/8
        route6 fe80::/64

lo: non-managed
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

DNS configuration:
        servers: 127.0.0.1 213.186.33.99
        interface: eth0
  • Find the name of your public interface:
nmcli connection show

NAME         UUID                                  TYPE      DEVICE
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  eth0
  • Disable automatic DNS modification, and enter the DNS you want:
nmcli con mod "Your interface name" ipv4.ignore-auto-dns yes
nmcli con mod "Your interface name" ipv4.dns "127.0.0.1 213.186.33.99"
  • Apply the configuration:
nmcli con down "Your interface name" && nmcli con up "Your interface name"
  • Check that the configuration has been properly applied:
nmcli | grep -E 'DNS|server|interface'

DNS configuration:
        servers: 127.0.0.1 213.186.33.99
        interface: eth0

On Windows

change-dns-servers

  • Then go to your public network adapter’s IPv4 configuration.

change-dns-servers

  • Add the servers you want to use:

change-dns-servers

In PowerShell, you can use the nslookup command to check which DNS server is used by default.

Go further

Logging in to an OVHcloud Public Cloud instance.

Becoming the root user and selecting a password.

Changing the hostname of a Public Cloud instance.

Join our community of users on https://community.ovh.com/en/.


These guides might also interest you...