PHPackages                             librenms/ip-util - 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. librenms/ip-util

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

librenms/ip-util
================

IPv4 and IPv6 Address/Network parsing utility classes

1.5(2y ago)6743↓50%1GPL-3.0-or-laterPHPPHP &gt;=5.6.4

Since May 8Pushed 2y ago2 watchersCompare

[ Source](https://github.com/librenms/ip-util)[ Packagist](https://packagist.org/packages/librenms/ip-util)[ Docs](http://www.librenms.org/)[ RSS](/packages/librenms-ip-util/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

[![CI](https://github.com/librenms/ip-util/actions/workflows/ci.yaml/badge.svg)](https://github.com/librenms/ip-util/actions/workflows/ci.yaml)

IPUtil
======

[](#iputil)

IPv4 and IPv6 Address/Network parsing utility classes

Requirements PHP 5.6+

Does not require bcmath or gmp.

Built for use in [LibreNMS - Network Monitoring Software](https://librenms.org).

Usage
-----

[](#usage)

#### Create a new IP instance

[](#create-a-new-ip-instance)

```
try {
    $ip = new IP('192.168.1.1');
    // or
    $ip = IP::parse('192.168.1.1');
} catch (InvalidIpException $e) {
    //
}
```

#### Check if a given string is a valid IP

[](#check-if-a-given-string-is-a-valid-ip)

```
IP::isValid('192.168.1.333');
```

You may specifically require IPv4 or IPv6 by using those classes directly:

```
$ip = IPv4::parse('192.168.1.1');
$ip = IPv6::parse('2600::');

IPv4::isValid('192.168.1.1');
IPv6::isValid('2600::');
```

#### Access the parsed IP

[](#access-the-parsed-ip)

```
echo $ip; // print nicely formated IP with cidr/prefix

echo $ip->address; // print just the address
echo $ip->cidr; // print the prefix length

echo $ip->compressed(); // Compresses IP addresses for easy reading
echo $ip->uncompressed(); // Uncompresses IP addresses for easy parsing
```

#### Handle network operations:

[](#handle-network-operations)

```
if ($ip->inNetwork('192.168.1.1/24')) {
    echo $ip->getNetwork();
}
```

#### Parse from Hex (useful for SNMP)

[](#parse-from-hex-useful-for-snmp)

```
$ip = IP::fromHexString('c0a801fe');
```

License
-------

[](#license)

Copyright (C) 2017-2018 Tony Murray

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see .

[LICENSE](LICENSE) contains a copy of the full GPLv3 licensing conditions.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~388 days

Recently: every ~485 days

Total

6

Last Release

990d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c8ae23512e547bece76cdb6a39f73fb0eab0291af6b97f9f8e3c962650afe24?d=identicon)[murrant](/maintainers/murrant)

---

Top Contributors

[![murrant](https://avatars.githubusercontent.com/u/39462?v=4)](https://github.com/murrant "murrant (17 commits)")

---

Tags

cidripip-toolsipv4ipv6networkphpsubnetipv6IPnetworkipv4cidrsubnetIP-Tools

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/librenms-ip-util/health.svg)

```
[![Health](https://phpackages.com/badges/librenms-ip-util/health.svg)](https://phpackages.com/packages/librenms-ip-util)
```

###  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)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

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

IPv4/IPv6 manipulation library for PHP

180738.8k11](/packages/rlanvin-php-ip)[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)
