PHPackages                             kubrick/lib-ip-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kubrick/lib-ip-tools

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kubrick/lib-ip-tools
====================

Various IPv4 ans IPv6 Tools

v1.0.0(6mo ago)031WTFPLPHPPHP &gt;=8.2

Since Nov 6Pushed 6mo agoCompare

[ Source](https://github.com/kubrrick/php-lib-ip-tools)[ Packagist](https://packagist.org/packages/kubrick/lib-ip-tools)[ Docs](https://clement.mouline.eu)[ RSS](/packages/kubrick-lib-ip-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

PHP Lib IP Tools
================

[](#php-lib-ip-tools)

[![Static Badge](https://camo.githubusercontent.com/33194a4f64b8b59f403249c4ffac73c760cb47a4f79287d909694c68ff1cf374/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d575446504c5f322e302d627269676874677265656e3f7374796c653d666c6174)](https://camo.githubusercontent.com/33194a4f64b8b59f403249c4ffac73c760cb47a4f79287d909694c68ff1cf374/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d575446504c5f322e302d627269676874677265656e3f7374796c653d666c6174)

Various IPv4 and IPv6 tools for PHP

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

lib-ip-tools requires PHP &gt;= 8.2.

```
composer require kubrick/lib-ip-tools
```

1. IPv4
-------

[](#1-ipv4)

### IPv4 address

[](#ipv4-address)

```
include 'vendor/autoload.php';

// Create an IPv4 address
$ipv4 = new \Kubrick\IpTools\IP\IPv4('10.0.0.1', 24);
```

Available attributes are:

- `->ipBinary` return the string equivalent binary ip address eg: 00001010000000000000000000000000
- `->ipAddress` return the ip address eg: 10.0.0.1
- `->networkMask` return the network mask eg: 24
- `->hostMask` return the host mask eg: 8
- `->binaryNetworkPart` return the network part as string equivalent eg: 000010100000000000000000
- `->binaryHostPart` return the host part as string equivalent eg: 00000001

### IPv4 Subnet calculator

[](#ipv4-subnet-calculator)

You can also

```
include 'vendor/autoload.php';

// Will return the next 5 addresses (.2 .3 .4 .5 .6)
$addresses = \Kubrick\IpTools\IP\IPv4SubnetCalculator::nextAddresses(
    new \Kubrick\IpTools\IP\IPv4('10.0.0.1', 24),
    5
);

// Will return ip addresses between .2 and .49 (given ip address are excluded)
$addresses = \Kubrick\IpTools\IP\IPv4SubnetCalculator::missingAddresses(
    [
        new \Kubrick\IpTools\IP\IPv4('10.0.0.1', 24),
        new \Kubrick\IpTools\IP\IPv4('10.0.0.10', 24),
        new \Kubrick\IpTools\IP\IPv4('10.0.0.50', 24)
    ]
);
```

2. IPv6
-------

[](#2-ipv6)

### IPv6 Address

[](#ipv6-address)

```
include 'vendor/autoload.php';

// Create an IPv6 address
$ipv6 = new \Kubrick\IpTools\IP\IPv6('2001::1', 64);
```

Available attributes are:

- `->ipBinary` return the string equivalent binary ip address eg: 00100000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
- `->ipAddress` return the ip address eg: 2001:0000:0000:0000:0000:0000:0000:0001
- `->ipAddressAbv` return the ip address on abbreviate format eg: 2001::1
- `->networkMask` return the network mask eg: 64
- `->hostMask` return the host mask eg: 64
- `->binaryNetworkPart` return the network part as string equivalent eg: 0010000000000001000000000000000000000000000000000000000000000000
- `->binaryHostPart` return the host part as string equivalent eg: 0000000000000000000000000000000000000000000000000000000000000001

### IPv6 Subnet calculator

[](#ipv6-subnet-calculator)

```
require 'vendor/autoload.php';

// Like ipv4 this will return the 5 new addresses
$addresses = \Kubrick\IpTools\IP\IPv6SubnetCalculator::nextAddresses(
    new \Kubrick\IpTools\IP\IPv6('2001::', 64),
    5
);

// This will return the 5 next IPv6 prefixes, you need to pass the ISP prefix eg. 48 and the number of prefixes you want
$addresses = \Kubrick\IpTools\IP\IPv6SubnetCalculator::nextPrefixes(
    new \Kubrick\IpTools\IP\IPv6('2001::', 56),
    48,
    5
);

// like ipv4 this will return missing ipv6 addresses
$addresses = \Kubrick\IpTools\IP\IPv6SubnetCalculator::missingAddresses(
    [
        new \Kubrick\IpTools\IP\IPv6('2001::', 64),
        new \Kubrick\IpTools\IP\IPv6('2001::5', 64),
        new \Kubrick\IpTools\IP\IPv6('2001::f', 64)
    ]
);

// like ipv4 this will return the missings prefixes, you juste have to provive the ISP prefix.
$addresses = \Kubrick\IpTools\IP\IPv6SubnetCalculator::missingPrefixes(
    [
        new \Kubrick\IpTools\IP\IPv6('2001:0:0:0000::', 56),
        new \Kubrick\IpTools\IP\IPv6('2001:0:0:0300::', 56)
    ],
    48
);
```

3. Mac address
--------------

[](#3-mac-address)

```
include 'vendor/autoload.php';

//create a mac address
$mac = new \Kubrick\IpTools\MAC\MacAddress('00:11:22:33:44:55');

// get the short format (001122334455)
echo $mac->toShort();

// get the long format (00:11:22:33:44:55)
echo $mac->toLong();

// you can also increment or decrement mac address (00:11:22:33:44:5a)
$mac->increment(5)->toLong()
```

Available methods are:

- `toShort():string` return the short format of the mac address eg. 001122334455
- `toLong():string` return the long format of the mac address eg. 00:11:22:33:44:55
- `getOUI():string` return the OUI eg. 001122
- `getNIC():string` return the NIC eg. 334455
- `incrementBy(int):self` increment mac address by the number given
- `decrementBy(int):self` decrement mac address by the number given

4. DHCPv6 DUID
--------------

[](#4-dhcpv6-duid)

```
require 'vendor/autoload.php';

$duid = new \Kubrick\IpTools\DUID\DUID('000423b6290dcb1b7113059a2247a7b12f05');

// getIdentifier() method will automatically display the good value, macAddress, uuid or identifier
echo $duid->getIdentifier();

// you can olso display other informations
// display DUID mac value if type LLT or LL
echo $duid->macAddress;

// display the pen number in case of DUID-EN type
echo $duid->pen;
```

Available attributes are:

- `->duid` returns the DUID without ":"
- `->type` returns the type of DUID
- `->link` returns the link type
- `->macAddress` returns the mac address
- `->pen` returns the iana pen number
- `->identifier` returns the identifier
- `->timestamp` returns the unix epoch timestamp
- `->uuid` returns the uuid

Available methods are:

- `getIdentifier()` returns the identifier base on duid type (eg mac address for LL &amp; LLT, ...)

Available static methods are:

- `::createDUIDLLT()` create a LLT DUID Type
- `::createDUIDLL()` create a LL DUID type
- `::createDUIDEN()` create an EN DUID type

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance67

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37eb5b59cf3b835c6831d43dae573a588380d6da545dd281a3cc8f010cba8179?d=identicon)[kubrrick](/maintainers/kubrrick)

---

Top Contributors

[![kubrrick](https://avatars.githubusercontent.com/u/2406740?v=4)](https://github.com/kubrrick "kubrrick (1 commits)")

---

Tags

IPnetworkipv4MACduidipv6NA

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kubrick-lib-ip-tools/health.svg)

```
[![Health](https://phpackages.com/badges/kubrick-lib-ip-tools/health.svg)](https://phpackages.com/packages/kubrick-lib-ip-tools)
```

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[rlanvin/php-ip

IPv4/IPv6 manipulation library for PHP

180738.8k11](/packages/rlanvin-php-ip)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)[jaaulde/php-ipv4

PHP classes for working with IPV4 addresses and networks.

1034.6k](/packages/jaaulde-php-ipv4)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
