PumpDnsSearch

Linux pump DHCP client and dns search order

One problem with the redhat dhcp client pump is that it doesn't deal with resolv.conf search entries. It takes whatever domain name the dhcp server assigns and uses that as a search entry, removing any entries you may have created manually. You can override this via an /etc/pump.conf directive, but you can only provide one fixed alternative search order. Thus, if you move a system between networks, sometimes you will get the wrong entries in your dns search path. That's no good.

To address this, I used pump's ability to call arbitrary scripts when it runs. First, here's my pump.conf:

 script /etc/pump-dns.sh

and here's pump-dns.sh:

 #!/bin/sh

 # a helper for pump to build correct /etc/resolv.conf files
 # as pump can only specify one dns search order, and you might
 # want several if system is moved between networks.
 #
 # Phil Hollenback
 # philiph_at_pobox_dot_com
 # 1/25/01
 #
 # $Id$

 # pump calls this script with
 # arg1 = up or down
 # arg2 = interface name (eth0)
 # arg3 = address

 tempfile=`mktemp /tmp/pump.XXXXXX` || exit 1

 case $3 in
  10.1.3.128)
    grep -v "^search" /etc/resolv.conf > $tempfile
    echo "search hollenback.org  dmz.coolcs.com coolcs.com" >> $tempfile || exit 1
    ;;
  10.1.1.65)
    grep -v "^search" /etc/resolv.conf > $tempfile
    echo "search inside.coolcs.com dmz.coolcs.com coolcs.com" >> $tempfile || exit 1
    ;;
  10.1.4.2)
    grep -v "^search" /etc/resolv.conf > $tempfile
    echo "search inside.infernosoft.com infernosoft.com dmz.coolcs.com coolcs.com" >> $tempfile || exit 1
    ;;
 esac

 mv $tempfile /etc/resolv.conf

Make sure this script is executable.

An improved version of this script would check network addresses instead of host addresses. Still, this is a start.

--phil 6/14/01

CategoryGeekStuff

CategoryLinuxStuff



Our Founder
ToolboxClick to hide/show
RecentChanges Click to hide/show