2

Is there a way to specify the address of a DNS server outside of using /etc/resolv.conf?

Reason: ( since someone will ask ) I have a system running LDME 1. I have installed a new drive and on it LDME 2.

Now since everything is configured the way I want in the LDME 1 system, I log into that and do cutsomize LDME 2 from a chroot.

The problem is that in LDME 2 /etc/resolv.conf is a symbolic link to a file in the /run directory. That file which is probably created in LDME 2 at boot does not exist in LDME 1.

If the LDME 2 /etc/resolv.conf were a regular file I would happily back it up, replace it with the LDME 1 version, do my stuff and restore. But I don't want to go around messing with freshly system generated symbolic link. Especially one that points outside a chroot jail.

3

Changing the pathname is hard, as it is hard-coded into glibc. However, you can use a bind-mount to mount a file instead of a directory (mount -B /tmp/my.resolv.conf /etc/resolv.conf). Unfortunately, that won't work with a broken symbolic link, as you can only bind-mount a regular file onto a regular file or a directory onto a directory. But is there something in /run you can bind mount over?

0

If you use a dns cache (which is a wise thing to do), you can specify a different file for the local dns cache server to use. For instance, for dnsmasq, you can configure it to use

resolv-file=/etc/resolv.dnsmasq.conf

which probably isn't a symbolic link.

Now, you still need to have 127.0.0.1 in your actual /etc/resolv.conf, but if it's already in there by any chance, and you just want to add an additional nameserver, this may help. Also, some dhcp clients admit "head" and "tail" files they prepend/append when resolv.conf is generated. They may help. Be careful, however, resolv.conf has a limited number of useful lines (I think it's usually 3, after that it's just ignored).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.