Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 May 2006 13:44:41 +1000
From:      "Murray Taylor" <MTaylor@bytecraft.com.au>
To:        <fbsd@a1poweruser.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   RE: Getting DHCP to use resolv.conf? AN ANSWER
Message-ID:  <04E232FDCD9FBE43857F7066CAD3C0F117C856@svmailmel.bytecraft.internal>

next in thread | raw e-mail | index | archive | help

> -----Original Message-----
> From: fbsd [mailto:fbsd@a1poweruser.com]=20
> Sent: Thursday, 4 May 2006 10:56 AM
> To: Murray Taylor
> Cc: freebsd-questions
> Subject: RE: Getting DHCP to use resolv.conf? AN ANSWER
>=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
> >
> >
> > Murray.
> >
> > 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 FreeBSD=20
> > 6.0 system.
> > I am also using the built in dhclient that comes with the base=20
> > install.
> > Could you post the isc_dhclient-script so I can compare it=20
> to the one=20
> > that comes with the base install for differences that may=20
> cause this=20
> > behavior?
> > Any other help would be appreciated.
> >
> >
> > When this script runs the logger statements do not create=20
> any message=20
> > in the targeted log files.
> > IF I execute the same logger statements from the command line they=20
> > work as expected.
> > This is the boot time messages with mail code commented out.
> >
> > 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.
> >
> >
> > IF I execute the cat command to issue the notification=20
> email from the=20
> > command line it works fine, but when used in the script I get these=20
> > messages during boot process.
> >
> > "~/.mailrc": No match.
> > DHCPREQUEST on dc0 to 255.255.255.255 port 67
> > /libexec/ld-elf.so.1: Shared object "libpcre.so.0" not=20
> found, required=20
> > 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.
> >
> >
> >
> >
> > #!/bin/sh
> >
> > #############  Start of refresh dhcpd dns ip script ############# #=20
> > This script will propagate to dhcpd the changed dns servers ip #=20
> > address which dhcp-client puts in resolv.conf.
> > #
> > # In dhcpd.conf replace the "option domain-name-servers" line with=20
> > this # #  include "/etc/dhcpd.name-servers"; # # Script=20
> uses the dhcpc=20
> > 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 #=20
> > and restart dhcp to reread dhcpd.conf containing new ISP dns ip=20
> > addresses.
> > #
> > # logging event and sending email to user root is optional.
> > #
> > # Note: All LAN machines using dhcpd will not get new ISP dns ip #=20
> > addresses until they reboot or their lease comes up for
> renewal.
> > #
> > # Each of the following lines must be one long line. IE: no wrap=20
> > around
> >
> ####################################################################
> >
> > # load my_domain_name_servers variable with ISP dns ip=20
> addresses from=20
> > dhcpc my_domain_name_servers=3D`echo $new_domain_name_servers=20
> | sed -e=20
> > 's/ /, /g'`
> >
> > # Create single line in file to be included in dhcpd.conf=20
> echo "option=20
> > domain-name-servers $my_domain_name_servers ;" >=20
> > /etc/dhcpd.name-servers.tmp
> >
> > # See if different from what production file contains cmp -s=20
> > /etc/dhcpd.name-servers.tmp /etc/dhcpd.name-servers if [ $?
> > -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 addresses=20
> > changed.
> >   # Write message to /var/log/dhcpd.log to document event.
> >   logger -p local1.warning -t dhclient Your ISP DNS IP addresses=20
> > changed.
> >
> >   # 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 that=20
> > your #ISP changed the IP address of their DNS servers.
> > 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=20
> the new ISP=20
> > dns #ip addresses until they reboot or their lease comes up for=20
> > renewal.
> > #EOF
> > fi
> > rm -f /etc/dhcpd.name-servers.tmp
> > ###############  End of refresh dhcpd dns ip script=20
> > ###################
>=20
> The script I sent are operational on FBSD 4.11 with the=20
> enter/exit-hooks scripts that are part of the base install.
> NB Dont forget I run the ipf firewall rewrite rules script=20
> manually as root when my IP number changes, but the DHCP ->=20
> resolv.conf is automatic via exit-hooks
>=20
> The scripts are always called by dhclient, what I put in them=20
> is what I attached.
>=20
> And I am also using Postfix ... As far as I remenber pcre is=20
> only needed by Postfix if you use pcre:<check-file> regular=20
> expression type files in main.cf. If you use=20
> regexp:<check-file> then pcre is not used.
>=20
>=20
> Murray Taylor
>=20
> ---------------------------------------------------------------
>=20
> Murry
> The only difference between us is I am running FreeBSD 6.0. &=20
> you 4.11.
> I had another exit-hooks script that worked fine when I was=20
> running all the versions in 4.x series.
> Currents tests show that even the IF statement in the script=20
> does not work either.
> I think this is turning into looking like a bug in the 6.0 release.
> I jumped from 4.11 to 6.0 doing a fresh install.
> Problem may have been in 5.x series also.
>=20
> I believe the recorder directives were added to the /etc/rc.d=20
> boot process as part of version 5.0 development series and=20
> the build in dhclient boot process was over looked so it no=20
> longer is getting executed at the time when all the resources=20
> it needs are active yet.

Hmm... seems odd  - does dhclient itself work upon boot ??
Do you get an IP address?=20
If so then I would think that the dhclient process is functioning
ok, so maybe try and code a _really simple_ enter or exit hook process
like=20

#!/bin/sh
logger "enter - got it"

make it executable and run it .

This will shove the quoted text into /var/log/messages


(BTW -- an "id 10 T" check...=20
/etc/dhclient-enter-hooks and /etc/dhclient-exit-hooks
are   -rwx-r-xr-x  root:wheel   arent they ??? )

Apart from all that, I'm out of ideas.

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.***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?04E232FDCD9FBE43857F7066CAD3C0F117C856>