From owner-freebsd-questions@FreeBSD.ORG Tue Dec 16 19:22:14 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2BC21065675 for ; Tue, 16 Dec 2008 19:22:14 +0000 (UTC) (envelope-from 240olofsson@telia.com) Received: from av6-1-sn3.vrr.skanova.net (av6-1-sn3.vrr.skanova.net [81.228.9.179]) by mx1.freebsd.org (Postfix) with ESMTP id 850068FC18 for ; Tue, 16 Dec 2008 19:22:14 +0000 (UTC) (envelope-from 240olofsson@telia.com) Received: by av6-1-sn3.vrr.skanova.net (Postfix, from userid 502) id 2CF9838B20; Tue, 16 Dec 2008 20:22:13 +0100 (CET) Received: from smtp3-1-sn3.vrr.skanova.net (smtp3-1-sn3.vrr.skanova.net [81.228.9.101]) by av6-1-sn3.vrr.skanova.net (Postfix) with ESMTP id E62BB382C2; Tue, 16 Dec 2008 20:22:12 +0100 (CET) Received: from [192.168.1.31] (90-227-65-237-no41.tbcn.telia.com [90.227.65.237]) by smtp3-1-sn3.vrr.skanova.net (Postfix) with ESMTP id B50AB37E4B; Tue, 16 Dec 2008 20:22:12 +0100 (CET) Message-ID: <4947FFE2.5050302@telia.com> Date: Tue, 16 Dec 2008 20:22:10 +0100 From: Roger Olofsson <240olofsson@telia.com> User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: glarkin@FreeBSD.org References: <4945035C.6040401@telia.com> <20081214132304.GA97385@free.bsd.loc> <49452D09.5030003@telia.com> <4946D452.2020104@FreeBSD.org> In-Reply-To: <4946D452.2020104@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Jeff Laine , raggen@raggens.net, freebsd-questions@freebsd.org Subject: Re: Canonical way for DHCP->IP->/etc/hosts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: raggen@raggens.net List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 19:22:15 -0000 Greg Larkin skrev: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Roger Olofsson wrote: >> >> Jeff Laine skrev: >>> On Sun, Dec 14, 2008 at 02:00:12PM +0100, Roger Olofsson wrote: >>>> Dear mailing list, >>>> >>>> I am sorry if this question has been asked over and over again - >>>> however the htdig search interface for the lists is somewhat shaky >>>> and gives referrer errors for me. >>>> >>>> Pre-conditions. >>>> Dualhomed firewalled FreeBSD7.1. One nic is LAN and the other >>>> dynamical IP from ISP. >>>> >>>> Question: What is the canonical way for catching the IP address from >>>> a DHCP assigned nic (from ISP that doesn't set hostname) and put the >>>> IP into /etc/hosts with a hostname? >>>> >>>> Reason for asking >>>> Firewall rules needs refreshing after new IP >>>> >>>> Possible answers: >>>> Create dhcp-exit-hooks (undocumented?) in /etc like so: >>>> >>>> #!/bin/sh >>>> >>>> if [ ! -z "$new_ip_address" ]; then >>>> IP=`ifconfig WAN | grep 'inet' | grep -v 'inet6' | cut -f 2 -d ' '` >>>> if [ ! -z "$IP" ]; then >>>> echo "$IP wan.local.domain wan" >> /etc/hosts >>>> >>>> >>>> >>>> fi >>>> fi >>>> >>> Hello. I think pf can handle with dhcp updates on interfaces pretty well. >>> If only I get your question right. >>> >>> > >> Hi Jeff and thank you for your reply, >> >> Yes, I know that pf will handle interfaces just fine, the question was >> not specific to pf though but more around dhclient, dhclient-script and >> the part of dhclient-script that calls the undocumented >> dhclient-exit-hooks. >> >> It might be handy to have the external IP assigned to a hostname - not >> only for pf. >> >> /R > > > Hi Roger, > > I wrote a blog post about automatically configuring /etc/hosts with a > DHCP dynamic IP address earlier this year: > http://blog.sourcehosting.net/tag/dhcp/. You can download a ZIP file > with the dhclient-exit-hook script in it near the bottom of the page. > > In my case, I also wrote some commands to update the Apache httpd.conf > file with the correct ServerName directive. You can easily remove that > from the script if you don't need it. > > If you need any assistance, let me know. > > Regards, > Greg > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (FreeBSD) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAklG1FEACgkQ0sRouByUApB1SACgmfJ4EtiyKdhyPgILZyc77Fxc > gHMAnRGGBWIya0Fg314LyrJZq9tTZvbj > =jHL5 > -----END PGP SIGNATURE----- > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > ------------------------------------------------------------------------ > > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.176 / Virus Database: 270.9.18/1849 - Release Date: 2008-12-15 09:01 > Hello Greg, Thank you very much. I guess this is the canonical way of doing it. /R