From owner-freebsd-questions@FreeBSD.ORG Sun Dec 14 13:00: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 EA5591065672 for ; Sun, 14 Dec 2008 13:00:14 +0000 (UTC) (envelope-from 240olofsson@telia.com) Received: from av7-2-sn3.vrr.skanova.net (av7-2-sn3.vrr.skanova.net [81.228.9.182]) by mx1.freebsd.org (Postfix) with ESMTP id ACABD8FC12 for ; Sun, 14 Dec 2008 13:00:14 +0000 (UTC) (envelope-from 240olofsson@telia.com) Received: by av7-2-sn3.vrr.skanova.net (Postfix, from userid 502) id 57261380BE; Sun, 14 Dec 2008 14:00:13 +0100 (CET) Received: from smtp3-2-sn3.vrr.skanova.net (smtp3-2-sn3.vrr.skanova.net [81.228.9.102]) by av7-2-sn3.vrr.skanova.net (Postfix) with ESMTP id 25EED37F89 for ; Sun, 14 Dec 2008 14:00:13 +0100 (CET) Received: from [192.168.1.31] (90-230-141-139-no41.tbcn.telia.com [90.230.141.139]) by smtp3-2-sn3.vrr.skanova.net (Postfix) with ESMTP id 0531037E47 for ; Sun, 14 Dec 2008 14:00:12 +0100 (CET) Message-ID: <4945035C.6040401@telia.com> Date: Sun, 14 Dec 2008 14:00:12 +0100 From: Roger Olofsson <240olofsson@telia.com> User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: User Questions Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: 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: Sun, 14 Dec 2008 13:00:15 -0000 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