Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Dec 2008 16:58:01 +0100
From:      Roger Olofsson <240olofsson@telia.com>
To:        Jeff Laine <wtf.jlaine@gmail.com>, freebsd-questions@freebsd.org
Subject:   Re: Canonical way for DHCP->IP->/etc/hosts
Message-ID:  <49452D09.5030003@telia.com>
In-Reply-To: <20081214132304.GA97385@free.bsd.loc>
References:  <4945035C.6040401@telia.com> <20081214132304.GA97385@free.bsd.loc>

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


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
>>
>> 	<refresh firewall rules here>
>>
>>     fi
>> fi
>>
> 
> Hello. I think pf can handle with dhcp updates on interfaces pretty well.
> If only I get your question right.
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.176 / Virus Database: 270.9.17/1847 - Release Date: 2008-12-13 16:56
> 

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



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