From owner-freebsd-questions@FreeBSD.ORG Thu May 4 00:06:12 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 828EA16A40E for ; Thu, 4 May 2006 00:06:12 +0000 (UTC) (envelope-from MTaylor@bytecraft.com.au) Received: from wolf.bytecraft.au.com (wolf.bytecraft.au.com [203.39.118.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9A46943D5C for ; Thu, 4 May 2006 00:06:00 +0000 (GMT) (envelope-from MTaylor@bytecraft.com.au) Received: from localhost (localhost [127.0.0.1]) by wolf.bytecraft.au.com (8.12.11/8.12.11) with ESMTP id k4405pWn077931; Thu, 4 May 2006 10:05:51 +1000 (EST) (envelope-from MTaylor@bytecraft.com.au) Received: from wolf.bytecraft.au.com ([127.0.0.1]) by localhost (wolf.bytecraft.au.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 77230-07; Thu, 4 May 2006 00:05:50 +0000 (GMT) Received: from svmarshal.bytecraft.au.com ([10.0.0.4]) by wolf.bytecraft.au.com (8.12.11/8.12.11) with ESMTP id k4405g8W077926; Thu, 4 May 2006 10:05:42 +1000 (EST) (envelope-from MTaylor@bytecraft.com.au) Received: from svmailmel.bytecraft.internal (Not Verified[10.0.0.24]) by svmarshal.bytecraft.au.com with MailMarshal (v5, 0, 3, 78) id ; Thu, 04 May 2006 10:05:42 +1000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Thu, 4 May 2006 10:05:42 +1000 Message-ID: <04E232FDCD9FBE43857F7066CAD3C0F117C83E@svmailmel.bytecraft.internal> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Getting DHCP to use resolv.conf? AN ANSWER Thread-Index: AcZuriJ7Wq5dIrD8QTq7WmyNpqAvVAAXzGkw From: "Murray Taylor" To: Cc: freebsd-questions Subject: RE: Getting DHCP to use resolv.conf? AN ANSWER X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2006 00:06:12 -0000 > -----Original Message----- > From: fbsd [mailto:fbsd@a1poweruser.com]=20 > Sent: Wednesday, 3 May 2006 10:36 PM > To: Murray Taylor > Subject: RE: Getting DHCP to use resolv.conf? AN ANSWER >=20 >=20 > > -----Original Message----- > > From: owner-freebsd-questions@freebsd.org > > [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of Lowell=20 > > Gilbert > > Sent: Friday, 28 April 2006 11:09 PM > > To: fbsd@a1poweruser.com > > Cc: freebsd-questions@freebsd.org > > Subject: Re: Getting DHCP to use resolv.conf? > > > > "fbsd" writes: > > > > > Does anyone have a script that does this, that they can share? > > > > It will be pretty similar to the script I posted recently=20 > for updating=20 > > your local named's forwarders list automatically. > > [Which is another approach to the same problem, and will generally=20 > > perform better.] > > > > > > > > -----Original Message----- > > > From: owner-freebsd-questions@freebsd.org > > > [mailto:owner-freebsd-questions@freebsd.org]On Behalf Of Bill > Moran > > > Sent: Wednesday, April 26, 2006 5:06 PM > > > To: Telting > > > Cc: freebsd-questions@freebsd.org > > > Subject: Re: Getting DHCP to use resolv.conf? > > > > > > > > > On Wed, 26 Apr 2006 13:56:57 -0700 > > > Telting wrote: > > > > > > > I would like to know how I can propagate the dns servers which > the > > > dhcp > > > > client puts in resolv.conf to dhcpd. I only see how I can > only > > > > explicitly list a domain server with "option > domain-name-servers". > > > How > > > > do I propogate non static dns servers? > > > > > > Write a script to updated the dhcpd.conf file when resolv.conf=20 > > > changes. dhclient allows you to create hooks that > > automagically run a > > > script of your choosing when a new lease is obtained. > > > > > > Or you could search the list archives for when this exact > > question was > > > asked a few weeks ago. > > > > > > -- > > > Bill Moran > > > Collaborative Fusion Inc. > > > > > > > >man dhclient-script > > > >and my enter and exit scripts below from my home boxen > > > > > >NB I use ddclient from ports to update dns stuff at dyndns.org and > the > >example.com should be replaced with your domain name in the > enter-hooks > >script. > > > >These are not totally automatic in what they do, as I prefer to > 'see and > >know' certain changes from my ISP so that is the reason for the > email > >setup.... > > > >Murray Taylor > > >=20 >=20 > -----Original Message----- > From: owner-freebsd-questions@freebsd.org > [mailto:owner-freebsd-questions@freebsd.org]On Behalf Of Murray Taylor > Sent: Sunday, April 30, 2006 7:56 PM > To: Lowell Gilbert > Cc: freebsd-questions@freebsd.org > Subject: RE: Getting DHCP to use resolv.conf? AN ANSWER >=20 >=20 > Murray. >=20 > Using your scripts as a example I coded the following script. > I can not get the notification logger and email to function. > I am running postfix launched by the sendmail wrappers on a=20 > FreeBSD 6.0 system. > I am also using the built in dhclient that comes with the=20 > base install. > Could you post the isc_dhclient-script so I can compare it to=20 > the one that comes with the base install for differences that=20 > may cause this behavior? > Any other help would be appreciated. >=20 >=20 > When this script runs the logger statements do not create any=20 > message in the targeted log files. > IF I execute the same logger statements from the command line=20 > they work as expected. > This is the boot time messages with mail code commented out. >=20 > dc0: link state changed to DOWN > dc0: no link ....dc0: link state changed to UP got link > dc0: link state changed to DOWN > DHCPREQUEST on dc0 to 255.255.255.255 port 67 > dc0: link state changed to UP > DHCPACK from 10.0.10.2 > dc0: link state changed to DOWN > bound to 10.0.10.4 -- renewal in 43200 seconds. >=20 >=20 > IF I execute the cat command to issue the notification email=20 > from the command line it works fine, but when used in the=20 > script I get these messages during boot process. >=20 > "~/.mailrc": No match. > DHCPREQUEST on dc0 to 255.255.255.255 port 67 > /libexec/ld-elf.so.1: Shared object "libpcre.so.0" not found,=20 > required by "send-mail" > dc0: link state changed to UP > DHCPREQUEST on dc0 to 255.255.255.255 port 67 DHCPACK from 10.0.10.2 > dc0: link state changed to DOWN > bound to 10.0.10.4 -- renewal in 43200 seconds. >=20 >=20 >=20 >=20 > #!/bin/sh >=20 > ############# Start of refresh dhcpd dns ip script=20 > ############# # This script will propagate to dhcpd the=20 > changed dns servers ip # address which dhcp-client puts in=20 > resolv.conf. > # > # In dhcpd.conf replace the "option domain-name-servers" line=20 > with this # # include "/etc/dhcpd.name-servers"; # # Script=20 > uses the dhcpc variables to build temp line in dhcpd format. > # Then compare temp content to production content. > # If different replace production content with new content=20 > from temp # and restart dhcp to reread dhcpd.conf containing=20 > new ISP dns ip addresses. > # > # logging event and sending email to user root is optional. > # > # Note: All LAN machines using dhcpd will not get new ISP dns=20 > ip # addresses until they reboot or their lease comes up for renewal. > # > # Each of the following lines must be one long line. IE: no=20 > wrap around=20 > #################################################################### >=20 > # load my_domain_name_servers variable with ISP dns ip=20 > addresses from dhcpc my_domain_name_servers=3D`echo=20 > $new_domain_name_servers | sed -e 's/ /, /g'` >=20 > # Create single line in file to be included in dhcpd.conf=20 > echo "option domain-name-servers $my_domain_name_servers ;" >=20 > /etc/dhcpd.name-servers.tmp >=20 > # See if different from what production file contains cmp -s=20 > /etc/dhcpd.name-servers.tmp /etc/dhcpd.name-servers if [ $?=20 > -gt 0 ]; then > # move the new file into place > mv /etc/dhcpd.name-servers.tmp /etc/dhcpd.name-servers > # restart dhcp using whatever is appropriate for your platform > #service dhcpd restart > #/usr/local/etc/rc.d/isc-dhcpd.sh restart -q > # Write message to /var/log/dhcpc.log to document event. > logger -p user.warning -t dhclient Your ISP DNS IP=20 > addresses changed. > # Write message to /var/log/dhcpd.log to document event. > logger -p local1.warning -t dhclient Your ISP DNS IP=20 > addresses changed. >=20 > # Send notification email to root user. This can wrap to next line. > # cat << EOF | mail -s "dhcp client changed ISP DNS IP addresses" > root > #The dhclient-exit-hook script was invoked and has determined=20 > that your #ISP changed the IP address of their DNS servers.=20 > The new values have been #auto updated to dhcpd.conf and dhcp=20 > restarted so they are now in effect. > # > #Note: All LAN machines using dhcpd will not start using the=20 > new ISP dns #ip addresses until they reboot or their lease=20 > comes up for renewal. > #EOF > fi > rm -f /etc/dhcpd.name-servers.tmp > ############### End of refresh dhcpd dns ip script=20 > ################### The script I sent are operational on FBSD 4.11 with the enter/exit-hooks scripts that are=20 part of the base install. NB Dont forget I run the ipf firewall rewrite rules script manually as root when my IP number changes, but the DHCP -> resolv.conf is automatic via exit-hooks =20 The scripts are always called by dhclient, what I put in them is what I attached. And I am also using Postfix ... As far as I remenber pcre is only needed by Postfix if you use pcre: regular expression type files in main.cf. If you use regexp: then pcre is not used. Murray Taylor Special Projects Engineer Bytecraft Systems P: +61 3 8710 2555 F: +61 3 8710 2599 D: +61 3 9238 4275 E: mtaylor@bytecraft.com.au=20 -- "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." =20 Albert Einstein=20 --=20 --------------------------------------------------------------- The information transmitted in this e-mail is for the exclusive use of the intended addressee and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of it, or the taking of any action in reliance upon this information by persons and/or entities other than the intended recipient is prohibited. If you received this in error, please inform the sender and/or addressee immediately and delete the material.=20 E-mails may not be secure, may contain computer viruses and may be corrupted in transmission. Please carefully check this e-mail (and any attachment) accordingly. No warranties are given and no liability is accepted for any loss or damage caused by such matters. --------------------------------------------------------------- ***This Email has been scanned for Viruses by MailMarshal.***