geeklab/localname

Look up names for ips using mDNS/Netbios/etc.

Maintainers

Package info

github.com/ellisgl/localname

pkg:composer/geeklab/localname

Transparency log

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

V1.1.0 2026-07-08 00:38 UTC

This package is auto-updated.

Last update: 2026-07-08 00:39:19 UTC


README

Resolve hostnames on local networks via mDNS, LLMNR, NetBIOS, and reverse DNS. Includes ARP-based MAC address lookup with IEEE OUI vendor identification.

Requirements

  • PHP >= 8.1
  • ext-sockets

Installation

composer require geeklab/localname

Then download the IEEE OUI database for MAC vendor lookups:

vendor/bin/update-oui.php data/oui.csv

Quick Start

use Geeklab\Localname\LocalName;

$resolver = LocalName::create(__DIR__ . '/data/oui.csv');
$result   = $resolver->lookup('192.168.1.100');

echo $result->ip;       // 192.168.1.100
echo $result->name;     // my-laptop.local
echo $result->protocol; // mdns
echo $result->mac;      // AA:BB:CC:DD:EE:FF
echo $result->vendor;   // Apple, Inc.

Resolvers

LocalName::create() tries each resolver in order and returns the first match:

Resolver Protocol Method
mDNS Multicast DNS (224.0.0.251:5353) PTR query
NetBIOS NBSTAT (port 137) Wildcard name query
LLMNR Link-Local Multicast (224.0.0.252:5355) PTR query
Reverse DNS System DNS gethostbyaddr()

Using Individual Resolvers

use Geeklab\Localname\Resolvers\Mdns;
use Geeklab\Localname\Resolvers\Netbios;
use Geeklab\Localname\Resolvers\Llmnr;
use Geeklab\Localname\Resolvers\ReverseDns;

$mdns = new Mdns(timeout: 3.0);
$name = $mdns->resolve('192.168.1.100'); // returns string or null

Getting All Results

$results = $resolver->lookupAll('192.168.1.100');

foreach ($results as $r) {
    printf("[%s] %s\n", $r->protocol, $r->name);
}

MAC Vendor Lookup

MAC vendor identification requires the IEEE OUI database. Download it with the included script:

vendor/bin/update-oui.php data/oui.csv

This downloads the IEEE OUI database to the path you specify. Without it, lookup() still works -- vendor will just be null.

Then pass the path when creating the resolver:

$resolver = LocalName::create(__DIR__ . '/data/oui.csv');

Running Tests

composer install
vendor/bin/phpunit

License

BSD-4-Clause