PumpDnsSearch

Note: You are viewing an old revision of this page. View the current version.

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

  1. a helper for pump to build correct /etc/resolv.conf files
  2. as pump can only specify one dns search order, and you might
  3. want several if system is moved between networks.

#

  1. Phil Hollenback
  2. philiph_at_pobox_dot_com
  3. 1/25/01

#

  1. $Id$
  2. pump calls this script with
  3. arg1 = up or down
  4. arg2 = interface name (eth0)
  5. 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



Our Founder
ToolboxClick to hide/show