Skip site navigation (1)Skip section navigation (2)
Date:      02 Dec 2003 17:30:01 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: getting DHCP-assigned IP address
Message-ID:  <444qwi4zva.fsf@be-well.ilk.org>
In-Reply-To: <3FCD0C92.7080508@code-fu.com>
References:  <3FCD0C92.7080508@code-fu.com>

next in thread | previous in thread | raw e-mail | index | archive | help
"Michael A. Smith" <msmith@code-fu.com> writes:

> Is there an easy way to get the IP address that DHCP has assigned to
> an interface?
> 
> I know I can do it the hard way -- parsing the results of ifconfig
> with regular expressions -- but I suspect there's a much easier way.

For most purposes, the easy way is to use the dhclient hooks scripts;
that way, you don't need to poll the values, either.  

"man 8 dhclient-script" for details, but my /etc/dhclient-exit-hooks
script is: 

    if [ x$old_ip_address != x$new_ip_address ]; then
            /usr/local/bin/noip
    fi



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