From owner-freebsd-net@FreeBSD.ORG Mon Oct 23 05:30:55 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B452816A40F for ; Mon, 23 Oct 2006 05:30:55 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.FreeBSD.org (Postfix) with SMTP id C909143D5D for ; Mon, 23 Oct 2006 05:30:50 +0000 (GMT) (envelope-from dougb@FreeBSD.org) Received: (qmail 12295 invoked by uid 399); 23 Oct 2006 05:30:50 -0000 Received: from localhost (HELO ?192.168.0.4?) (dougb@dougbarton.us@127.0.0.1) by localhost with SMTP; 23 Oct 2006 05:30:50 -0000 Message-ID: <453C5386.5080102@FreeBSD.org> Date: Sun, 22 Oct 2006 22:30:46 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: joe@joeholden.co.uk References: <453C0E42.4010604@joeholden.co.uk> In-Reply-To: <453C0E42.4010604@joeholden.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: net@freebsd.org Subject: Re: Instructing dhclient to set hostname of client X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2006 05:30:55 -0000 Joe Holden wrote: > Hi all, > > Is it possible to get dhclient to resolve the ip its been given, and set > that as the hostname? (6.2-PRE) For future reference, this really belongs on freebsd-questions. If you know for sure that the DHCP server is going to send you a hostname, then you can put this in your /etc/dhclient.conf: request subnet-mask, routers, broadcast-address, domain-name, host-name, domain-name-servers; (obviously those aren't all related to your hostname, but probably a good idea anyway). If you're talking about a laptop where you're not sure what the DHCP server is going to send you, then I have this in /etc/rc.local: for ip in `ifconfig | awk '/inet / {print $2}'`; do case "${ip}" in 127.0.0.1|0.0.0.0) ;; *) newhost=`host ${ip} | cut -f5 -d ' '` case "${newhost}" in ''|*NXDOMAIN*) ;; *\.*) hostname ${newhost%.} sleep 1 break ;; esac ;; esac done Combine that with a default hostname in /etc/rc.conf[.local] and you're good to go. hth, Doug -- This .signature sanitized for your protection