need help working around specifying interface name on dhcpd invocation

Glenn Satchell Glenn.Satchell at uniq.com.au
Mon Mar 27 10:42:19 UTC 2006


>X-Original-To: dhcp-users at webster.isc.org
>From: "Gordon A. Lang" <glang at goalex.com>
>To: <dhcp-users at isc.org>
>Subject: need help working around specifying interface name on dhcpd invocation
>Date: Mon, 27 Mar 2006 02:14:01 -0500
>X-MailScanner-Information: Please contact the ISP for more information
>X-MailScanner: Found to be clean
>X-MailScanner-SpamScore: sss
>X-archive-position: 289
>X-ecartis-version: Ecartis v1.0.0
>X-original-sender: glang at goalex.com
>List-software: Ecartis version 1.0.0
>X-List-ID: <dhcp-users.isc.org>
>X-list: dhcp-users
>
>I got dhcpd working with USE_SOCKETS and not ALIAS_NAMES_PERMUTED on Solaris 
>10 in a whole-root-zone (not the global zone), but so far I've only been 
>able to get it to work if I specify the precise sub-interface name during 
>invocation:
>
>e.g. dhcpd  eri0:3
>
>Is there a way to get dhcpd to not require the interface name under these 
>conditions?
>
>Needing to know the specific sub-interface name is a problem because the 
>interface name changes according to the zone boot order on Solaris 10.
>
>If there isn't a work around with the current release of dhcpd, then is 
>there a *simple* way (e.g. available script or utility) to return the 
>interface name for a given IP address?
>
>--
>Gordon A. Lang 
>
Perhaps not the most perfect example of perl coding, but I think this
will do the trick. If the script is called getint, then you use it like
so:

dhcpd `getint 192.168.1.1`

#! /usr/bin/perl -w
my $ip = $ARGV[0] or die "usage: $0 ip-address\n";
open (IF, "/usr/sbin/ifconfig -a |") or die "can't run ifconfig: $!";
#lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 
index 1
#        inet 127.0.0.1 netmask ff000000 
#hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
#        inet 192.168.14.28 netmask ffffff00 broadcast 192.168.14.255
my $interface;
while (<IF>) {
    if ( /^([a-z0-9:]+): flags/ ) {
        $interface = $1;
    }
    elsif ( /inet (\d+\.\d+\.\d+\.\d+) netmask/ ) {
        if ($ip eq $1) {
            print $interface, "\n";
            last;
        }
    }
}
close(IF);

regards,
-glenn



More information about the dhcp-users mailing list