Hi All,
Can anybody guide me for the little issue.
I need to add few nameservers in /etc/resolv.conf
and after every time reboot, that entry should be edited in /etc/resolv.conf
is there any way?
Thanks in advance.
Hi All,
Can anybody guide me for the little issue.
I need to add few nameservers in /etc/resolv.conf
and after every time reboot, that entry should be edited in /etc/resolv.conf
is there any way?
Thanks in advance.
Short summary tied to the thread: needs extra DNS servers to survive reboots on a desktop where the network/DHCP is out of his control; pointed at DHCP-side fixes. For a durable, local fix, the correct approach depends on what is actually managing resolver updates on that machine — modern systems commonly use systemd-resolved, a resolver helper, or NetworkManager, and each has its own place to set persistent DNS.
If the host uses systemd-resolved, add your servers into the resolver configuration and restart the resolver. For example, update the resolver config file and then reload the service (see the systemd resolver documentation for exact keys and behavior):
# example: /etc/systemd/resolved.conf
[Resolve]
DNS=1.1.1.1 8.8.8.8 If your distribution uses the resolvconf helper, put persistent lines into the helper’s drop-in files (head/base/tail) and update resolvconf so the generated resolv.conf includes them. See the Debian resolvconf notes for the recommended locations and workflow.
If NetworkManager manages the connection, configure the connection to use static DNS instead of accepting one from DHCP (you can do this per-connection with the CLI or the GUI). A per-connection change avoids the resolver file being clobbered at every DHCP lease event; see the NetworkManager docs for the exact nmcli options.
Quick troubleshooting tips: check whether /etc/resolv.conf is a regular file or a symlink (if it points into /run/ or /var/run, some manager owns it). That tells which subsystem to configure. If there is no root access to the machine, real, persistent system-wide changes are not possible locally — the practical alternatives are asking the sysadmin to apply the change, using an application-level DNS option (browser DoH or an SSH SOCKS proxy), or arranging a brief privileged change (dispatcher/if-up script) performed once by someone with root. Relevant docs: systemd-resolved (https://www.freedesktop.org/software/systemd/man/resolved.conf.html), resolvconf (https://wiki.debian.org/resolvconf), NetworkManager (https://wiki.archlinux.org/title/NetworkManager).
I believe you can add your additional DNS servers into the /etc/conf.d/dhcpd.conf as an option line, like so
option domain-name-servers
of course location of the dhcpd.conf will vary depending on the distro you use ;)
ooh, just noticed you said for normal users...you need to be root to make those changes, I don't think there is a way a non-admin can make those changes since it is a system setting and I've seen bad DNS entries really jack a system up
Dear icaruslnx,
if i have root a/c, then can you pl. tell me how can i set it automatically?
I don't have any DHCP client linux machines to try this on (mostly static servers) and it depends on what distro you're using. From the docs I find on this it looks like you can edit the dhcpd.conf to add in extra DNS servers when DHCP does it's thing.
In the file using whichever editor you choose (I'm a VI guy but gedit or some other graphical notepad type app might be easier to use). add a line at the end with the nameserver you want to add like this replacing the 127.0.0.1 with the name server of your choice, additional servers can be added seperated with a comma ","
prepend domain-name-servers 127.0.0.1; If something is messed up and this causes DHCP to fail, remove the line and restart the network.
Dear icaruslnx,
I am user of my desktop, so i cant do any changes in dhcp server. DHCP server is mainted by Sys. Admin.
So i need to add extra name servers entry on my local system after every reboot.
I had also add /etc/profile file with few shell command,s and it is also working. But for that i need to login in root a/c after every reboot.
And one more thing, if i edit /etc/ then it is not getting executing. due to limited access to user.
so now i think, i need to writer some different script and need to put it in /etc/init.d
Let see what happen ahead. If you find some script for it. then let me know i will try with that one.
Ok!
I don't have any DHCP client linux machines to try this on (mostly static servers) and it depends on what distro you're using. From the docs I find on this it looks like you can edit the dhcpd.conf to add in extra DNS servers when DHCP does it's thing.
In the file using whichever editor you choose (I'm a VI guy but gedit or some other graphical notepad type app might be easier to use). add a line at the end with the nameserver you want to add like this replacing the 127.0.0.1 with the name server of your choice, additional servers can be added seperated with a comma ","
prepend domain-name-servers 127.0.0.1;If something is messed up and this causes DHCP to fail, remove the line and restart the network.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.