Re: [RFC] Automated generation of /etc/resolv.conf from the rc.d script



On Thursday 24 April 2008 08:21:40 am John Baldwin wrote:
On Monday 14 April 2008 11:44:13 am Eygene Ryabinkin wrote:
Poul-Henning, good day.

Fri, Dec 14, 2007 at 02:07:00PM +0300, Eygene Ryabinkin wrote:
Fri, Dec 14, 2007 at 10:57:38AM +0000, Poul-Henning Kamp wrote:
In message <dEZnki0Fi32EvMrDEnqcgDeNQSc@Bbw9J2Iynx0QjNoWuQ4YSitYS3A>,
Eygene Ryabinkin writes:
It should be possible to run a local named even when we run DHCP,
and it shuld be an option, to have it automatically forward to the
DNS servers we learn from DHCP.

This can be achieved with the script /etc/dhclient-exit-hooks that
will create the file with named 'forwarders' clause [...]

Yes, I know that, but I would like to see it controllable from rc.conf
like the rest of our network configuration.

OK, since running local DNS instance is a neat idea, I will try to
draft the modifications for the dhclient-exit-hooks, as I described
in the previous mail.

At last, I did the needed modifications: patches against 7.0 from
yesterday, April 13th, are attached. The first one enables the
creation of /etc/resolv.conf from rc.conf variables and the second
brings the named forwarders rewriting using values obtained via
DHCP. I had touched dhclient-script, but it was really needed,
because it is not good to have simular functionality in /etc/rc.d/resolv
and in the dhclient-script.

I decided not to cope with modifications of /etc/namedb/named.conf,
but rather to create other file, /etc/namedb/named.forwarders.conf,
that should be included from the main configuration.

I am living for two days with this configuration (DHCP + local named
instance) and no problems were spotted yet.

Testing and feedback are more than welcome.

You can already override the domain name and DNS servers (including either
overriding, providing a default, or prepending or appending to the list) via
setings in /etc/dhclient.conf, so I don't think new rc.conf variables for
that would be warranted. Updating named.conf to forward is a neat idea.
Howver, on my laptop on HEAD I've ended up just running nscd instead of a
local DNS server and doing a 'nscd -I hosts' when I get a new lease to flush
the host cache. When I get to my laptop I'll post my bits of
dhclient-exit-hooks and dhclient.conf to make this work.

On my laptop now so here are the relevant bits:

In /etc/rc.conf:

nscd_enable="YES"

In /etc/nsswitch.conf:

hosts: cache files dns

In /etc/dhclient.conf:

append domain-name " yahoo.com freebsd.org baldwin.cx";

(This adds more domains to the 'search' line in /etc/resolv.conf.)

And my /etc/dhclient-exit-hooks (you can ignore the ntp bits):

if [ "$exit_status" -eq 0 ]; then
case $reason in
BOUND|REBOOT|TIMEOUT)
# If we have an NTP server, run ntpdate
if [ -n "$new_ntp_servers" ]; then
$LOGGER "New NTP Servers ($interface): $new_ntp_servers"
ntpdate -s $new_ntp_servers
fi

# Flush host cache since DNS may have changed
nscd -I hosts
;;
esac
fi

This will all work on 7.0 as well since it has nscd. This is also good bit
simpler than running a local DNS server if all you want to do is cache DNS
lookups.

--
John Baldwin
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Qs Regarding DNS
    ... >but via this method i am not sure that i have all the ips of site. ... since most DNS servers that service regular "anybody" Internet ... finding out all your hosts without brute force (i.e., ... I could throw in a good website's (like I don't know, Google ...
    (Security-Basics)
  • Re: DNS Forwarders - weird question
    ... > their DNS servers and all is well. ... Their hosts resolve off their DNS ... > requests to bigcompany's internal DNS servers, ...
    (microsoft.public.windows.server.dns)
  • Re: Intercept DNS request
    ... So to the rest of the internet; ... in the hosts file per pc, but that just seems like to much work. ... to specify the IP addresses of your ISPs DNS servers. ... Microsoft MVPs ...
    (microsoft.public.windows.server.sbs)
  • Re: dig and dns question
    ... are the same requests that slave dns servers use to mimmik zone ... configuration files across multiple dns servers incase if one goes down ... ('zone transfers') ... That command is not showing any other hosts. ...
    (comp.os.linux.misc)
  • Re: DNS question with VPN
    ... :After establishing VPN connection (with an XP, using Cisco VPN client ... Are the two DNS servers on the same LAN, or is one perhaps on the outside? ... :Hosts listed below in the router config will respond with 67.x.x.x IP, ... :while hosts not listed here respond with 192.168.180.x IP address. ...
    (comp.dcom.sys.cisco)