dhclient-script bug?

Nathan Strong gblues at gmail.com
Fri Aug 25 03:50:59 UTC 2006


I glanced over the available archives and didn't see anything
relevant, and it took my own analysis to figure out what was going
wrong.

system info:

Kernel: Linux x86 2.6.16.27
dhcp release version: 3.0.4
router: Linksys WRT54GS

ISSUE: When using dhclient to request an IP address from a Linksys
WRT54GS, the IP address is correctly assigned but the DNS servers
don't get written to the /etc/resolv.conf file.

Here is my dhclient.conf file:

timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;

interface "eth0" {
        request subnet-mask, domain-name-servers, host-name;
        require subnet-mask, domain-name-servers;
        script "/sbin/dhclient-script";
}

Now, here's the relevent portion of /sbin/dhclient-script:

make_resolv_conf() {
  if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
    echo search $new_domain_name >/etc/resolv.conf
    chmod 644 /etc/resolv.conf
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
    done
  fi
}

The resolv.conf file only gets created if the $new_domain_name field
returns a value; if it comes back empty, resolv.conf is left
completely untouched! Or, in my case, uncreated at all.

I first tried simply setting the domain on my router to "cableone.net"
(my ISP) but I quickly lost DNS connectivity entirely! Therefore I had
to modify /sbin/dhclient-script to the following:

make_resolv_conf() {
  if [ "x$new_domain_name" != x ]; then
    echo search $new_domain_name >/etc/resolv.conf
  else
    rm -f /etc/resolv.conf
    touch /etc/resolv.conf
  fi
  chmod 644 /etc/resolv.conf
  if [ "x$new_domain_name_servers" != x ]; then
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
    done
  fi
}

Any thoughts on this vs. exporting a bogus domain into
$new_domain_name to fool the script into running?

Nathan


More information about the dhcp-users mailing list