How to use custom DNS ?

Hi,

I am using mobile broadband (usb modem) to connect to the Internet.

I want to use Google DNS. I have configured the connection like this

https://paste.opensuse.org/77700669

But when I view the resolv.conf I see this

~> cat /etc/resolv.conf 
### /etc/resolv.conf file autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
#     NETCONFIG_DNS_STATIC_SEARCHLIST
#     NETCONFIG_DNS_STATIC_SERVERS
#     NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
#     NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
nameserver 122.160.237.197
nameserver 59.144.127.117
nameserver 8.8.8.8


As you can see the system is still using my ISP’s DNS servers.

How to use custom DNS ?

If you really want to set your own, you can just edit them into “/etc/resolv.conf”

Make sure that you remove that line the comments say to remove. Or remove all comment lines. And make a backup of the version you like, just in case some other software changes it (some VPN software does that).

And, if you change your mind and want to get the original “resolv.conf” back, you can just remove that file and reboot. It will be recreated during boot.

Or, read the comments in “/etc/resolv.conf”:

  • Edit the following parameters in “/etc/sysconfig/network/config”:
    [LIST]
  • NETCONFIG_DNS_STATIC_SEARCHLIST
  • NETCONFIG_DNS_STATIC_SERVERS
  • NETCONFIG_DNS_FORWARDER

[/LIST]
“/etc/sysconfig/network/config” is fully commented with explanations of what these parameters do.
There’s also the “netconfig” (8) man page …
There’s also this openSUSE documentation: <https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.network.html#sec.network.yast.change.host>.

Edit the following parameters in “/etc/sysconfig/network/config”:

  • NETCONFIG_DNS_STATIC_SEARCHLIST
  • NETCONFIG_DNS_STATIC_SERVERS
  • NETCONFIG_DNS_FORWARDER

This ^^ worked.

Thanks to both.

@suse_kid:

Thanks for the feedback.