Score:0

How to change DNS servers in /etc/resolv.conf?

bv flag
JPX

I have installed dnsmasq and disabled systemd-resolved. dnsmasq will only use local hosts.dnsmasq and not forward any request.

addn-hosts=/home/users/hosts.dnsmasq
resolv-file=

The problem is that my /etc/resolv.conf is overwritten and nameserver is set to 127.0.0.1 which is dnsmasq and I would like to set it 8.8.8.8

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.1

How can I manually set name server to 8.8.8.8?

Configuring name servers to /etc/resolvconf/resolv.conf.d/base doesn't work.

Ubuntu 22.04.2 LTS

Edit 1: Changing server in /etc/netplan/50-cloud-init.yaml won't make any difference. This was the default setting in OVH's VPS.

    nameservers:
        addresses:
        - 213.186.33.99
        search: []
Score:0
cn flag

You tell one of the tools that manipulate /etc/resolv.conf to add it. If you use wifi see the network settings and tab ipv4; it has a DNS option there when you disable "automatic".

There is also netplan. There will be an example in /etc/netplan but a generic version using google DNS would be:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      dhcp4: no
      addresses:
        - 192.168.121.1/24
      gateway4: 192.168.1.1
      nameservers:
          addresses: [8.8.8.8, 8.8.4.4]

8.8.4.4 as the 2nd DNS.

JPX avatar
bv flag
JPX
That won't make any difference. 127.0.0.1 is still in resolv.conf.
cn flag
and always will. that is localhost not a DNS name.
JPX avatar
bv flag
JPX
No it won't. Originally it was 213.186.33.99 which is in netplan but after installing dnsmasq it changed to 127.0.0.1. I don't want to use localhost as my DNS server. Dnsmasq is used to serve only specific NS records. I have done this in older Debian where you could just set DNS servers in /etc/resolc.conf.
cn flag
and Ubuntu started using netplan a while back.
Score:0
bv flag
JPX

There's a setting DNSMASQ_EXCEPT in file /etc/default/dnsmasq

# If the resolvconf package is installed, dnsmasq will tell resolvconf
# to use dnsmasq under 127.0.0.1 as the system's default resolver.
# Uncommenting this line inhibits this behaviour.
#DNSMASQ_EXCEPT="lo"

DNSMASQ_EXCEPT="lo" will remove 127.0.0.1 from /etc/resolv.conf and you can manually add nameserver 8.8.8.8.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.