ip

ip interprets IPv4 and IPv6 addresses, classifies their scope, converts numeric forms and calculates CIDR network boundaries entirely in PHP.

NetworkVersion 1.2.2Stable
lil-terminal

Overview

Use ip when you need deterministic address math rather than a remote network request: convert IPv4 forms, expand IPv6, inspect private or loopback scope, or calculate the network and range represented by a prefix.

An address and a CIDR network answer different questions

Without a prefix, ip describes one address. With /prefix, it calculates the network boundaries and range. ip me and ip server are different again: they read addresses from the current HTTP request and hosting environment.

Syntax

lil-terminal
ip <address|integer|hex|me|server>[/prefix]

Reference

ip 192.168.1.1

inspect an IPv4 address, numeric forms and scope

ip 3232235777

convert an unsigned integer to IPv4 and inspect it

ip 0xC0A80101

convert hexadecimal to IPv4 and inspect it

ip 192.168.1.10/24

show IPv4 network, mask, wildcard, broadcast and range

ip 2001:db8::1

show compressed and expanded IPv6 forms and scope

ip 2001:db8::1/64

show the IPv6 network, last address and range

ip me

inspect the current visitor address

ip server

inspect the current server address

Deterministic forms

The same IPv4 address can be entered as dotted decimal, an unsigned integer or hexadecimal. CIDR input adds the calculated network boundaries. IPv6 output includes compressed, expanded and hexadecimal forms; a prefix additionally shows the network, last address, full range and address count. me and server depend on the current HTTP request and hosting environment.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Compare server and visitor addresses

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install ip
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install ip -m
Exact public version

Install exactly this published version.

install ip -v 1.2.2
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade ip
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install ip -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Compare server and visitor addresses
ip server | ip me
Address  203.0.113.10
Family   IPv4
Scope    documentation

Address  198.51.100.24
Family   IPv4
Scope    documentation
Convert an unsigned integer to IPv4 and inspect it
ip 3232235777
Address    192.168.1.1
Family     IPv4
Scope      private
Integer    3232235777
Hex        0xC0A80101
Bytes      192.168.1.1
Convert hexadecimal to IPv4 and inspect it
ip 0xC0A80101
Address    192.168.1.1
Family     IPv4
Scope      private
Integer    3232235777
Hex        0xC0A80101
Bytes      192.168.1.1
Show IPv4 network, mask, wildcard, broadcast and range
ip 192.168.1.10/24
Address    192.168.1.10
Family     IPv4
Scope      private
Integer    3232235786
Hex        0xC0A8010A
Bytes      192.168.1.10
CIDR       192.168.1.0/24
Network    192.168.1.0
Netmask    255.255.255.0
Wildcard   0.0.0.255
Broadcast  192.168.1.255
Range      192.168.1.0 – 192.168.1.255
Addresses  256
Show compressed and expanded IPv6 forms and scope
ip 2001:db8::1
Address     2001:db8::1
Family      IPv6
Scope       documentation
Compressed  2001:db8::1
Expanded    2001:0db8:0000:0000:0000:0000:0000:0001
Hex         0x20010DB8000000000000000000000001
Show the IPv6 network, last address and range
ip 2001:db8::1/64
Address     2001:db8::1
Family      IPv6
Scope       documentation
Compressed  2001:db8::1
Expanded    2001:0db8:0000:0000:0000:0000:0000:0001
Hex         0x20010DB8000000000000000000000001
CIDR        2001:db8::/64
Network     2001:db8::
Last        2001:db8::ffff:ffff:ffff:ffff
Range       2001:db8:: – 2001:db8::ffff:ffff:ffff:ffff
Addresses   18446744073709551616
Inspect the current visitor address
ip me
Address  198.51.100.24
Family   IPv4
Scope    documentation
(example: actual visitor address depends on the request)
Inspect the current server address
ip server
Address  203.0.113.10
Family   IPv4
Scope    documentation
(example: actual server address depends on the host)
Reject an invalid IP address
ip 999.999.999.999
Invalid IP address

File used in this example: sandbox/config/app.json

The example uses a file or directory from the protected /sandbox/ documentation workspace.

{
  "name": "lil-sandbox",
  "debug": true,
  "features": ["files", "code", "archives"],
  "limits": {
    "upload_mb": 2,
    "history": 25
  }
}

Related documentation

Current public release

v1.2.22026-08-08

Clearer visitor and server forms

Separates request-derived me/server forms from deterministic address conversions in the local reference.