π A powerful command-line interface for IP address operations, powered by ip-navigator.
β¨ Validation
- Validate IPv4 addresses, subnet masks, and CIDR notation
- Batch validation of multiple IP addresses
- Clear, informative error messages
π Conversion
- Convert between decimal, binary, and integer formats
- Convert between CIDR notation and subnet masks
- View all representations of an IP address at once
π Subnet Operations
- Calculate network and broadcast addresses
- Get comprehensive subnet information
- Check if an IP belongs to a subnet
π οΈ IP Operations
- Classify IPs as public or private
- Get next/previous IP addresses
- Generate IP ranges
- Compare IP addresses numerically
npm install -g ip-navigator-clinpm install ip-navigator-clinpx ip-navigator-cli <command>Boost your productivity with convenient aliases and completions:
git clone https://github.com/clebertmarctyson/oh-my-zsh-ipnav \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ipnavAdd ipnav to your plugins in ~/.zshrc:
plugins=(
# ... other plugins
ipnav
)Available shortcuts:
ipvβipnav validate-ipipbinβipnav to-binaryipclassβipnav classify- And many more...
View full documentation for oh-my-zsh β
# Validate an IP address
ipnav validate-ip 192.168.1.1
# Get subnet information
ipnav subnet-info 192.168.1.100 255.255.255.0
# Convert IP to binary
ipnav to-binary 192.168.1.1
# Classify IP as public or private
ipnav classify 8.8.8.8
# Generate IP range
ipnav range 192.168.1.1 192.168.1.10Validate an IPv4 address.
ipnav validate-ip 192.168.1.1
# β
Valid IP address: 192.168.1.1
ipnav vip 256.1.2.3
# β Invalid IP address: 256.1.2.3Validate a subnet mask.
ipnav validate-mask 255.255.255.0
# β
Valid subnet mask: 255.255.255.0Validate CIDR notation.
ipnav validate-cidr 192.168.1.0/24
# β
Valid CIDR notation: 192.168.1.0/24Validate multiple IP addresses at once.
ipnav validate-batch 192.168.1.1 10.0.0.1 256.1.1.1 8.8.8.8
# β
192.168.1.1
# β
10.0.0.1
# β 256.1.1.1
# β
8.8.8.8
# π Summary: 3 valid, 1 invalid (4 total)Options:
-q, --quiet- Only show invalid addresses
Convert IP address to binary representation.
ipnav to-binary 192.168.1.1
# IP Address: 192.168.1.1
# Binary: 11000000.10101000.00000001.00000001Options:
-s, --spaces- Use spaces instead of dots as separators
Convert binary to IP address.
ipnav from-binary 11000000.10101000.00000001.00000001
# Binary: 11000000.10101000.00000001.00000001
# IP Address: 192.168.1.1Convert IP address to 32-bit integer.
ipnav to-integer 192.168.1.1
# IP Address: 192.168.1.1
# Integer: 3232235777
ipnav int 192.168.1.1 --hex
# IP Address: 192.168.1.1
# Integer: 3232235777
# Hexadecimal: 0xC0A80101Options:
-h, --hex- Display result in hexadecimal
Convert 32-bit integer to IP address.
ipnav from-integer 3232235777
# Integer: 3232235777
# IP Address: 192.168.1.1Convert CIDR prefix to subnet mask.
ipnav cidr-to-mask 24
# CIDR Prefix: /24
# Subnet Mask: 255.255.255.0
# Binary: 11111111.11111111.11111111.00000000Convert subnet mask to CIDR prefix.
ipnav mask-to-cidr 255.255.255.0
# Subnet Mask: 255.255.255.0
# CIDR Prefix: /24
# Binary: 11111111.11111111.11111111.00000000Show all representations of an IP address.
ipnav convert 192.168.1.1
# π’ IP Address Representations:
# ββββββββββββββββββββββββββββββββββββββββ
# Decimal: 192.168.1.1
# Binary: 11000000.10101000.00000001.00000001
# Integer: 3232235777
# Hexadecimal: 0xC0A80101
# ββββββββββββββββββββββββββββββββββββββββGet comprehensive subnet information.
ipnav subnet-info 192.168.1.100 255.255.255.0
# π Subnet Information:
# ββββββββββββββββββββββββββββββββββββββββ
# IP Address: 192.168.1.100
# Subnet Mask: 255.255.255.0
# Network Address: 192.168.1.0
# Broadcast Address: 192.168.1.255
# First Usable: 192.168.1.1
# Last Usable: 192.168.1.254
# Total Hosts: 256
# Usable Hosts: 254
# ββββββββββββββββββββββββββββββββββββββββ
# Using CIDR notation
ipnav sinfo 192.168.1.100 --cidr 24Options:
-c, --cidr <prefix>- Use CIDR notation instead of subnet mask
Calculate network address from IP and subnet mask.
ipnav network-address 192.168.1.100 255.255.255.0
# Network Address: 192.168.1.0Calculate broadcast address from IP and subnet mask.
ipnav broadcast-address 192.168.1.100 255.255.255.0
# Broadcast Address: 192.168.1.255Check if an IP address belongs to a subnet.
ipnav in-subnet 192.168.1.100 192.168.1.0 255.255.255.0
# β
192.168.1.100 belongs to subnet 192.168.1.0/255.255.255.0
ipnav insubnet 10.0.0.1 192.168.1.0 255.255.255.0
# β 10.0.0.1 does NOT belong to subnet 192.168.1.0/255.255.255.0Classify IP address as public or private.
ipnav classify 192.168.1.1
# π IP Classification:
# ββββββββββββββββββββββββββββββββββββββββ
# IP Address: 192.168.1.1
# Type: π Private IP
# Standard: RFC 1918 (Private Network)
# Range: 192.168.0.0 - 192.168.255.255
# ββββββββββββββββββββββββββββββββββββββββ
ipnav class 8.8.8.8
# Type: π Public IPGet the next IP address in sequence.
ipnav next 192.168.1.1
# Current: 192.168.1.1
# Next 1: 192.168.1.2
ipnav next 192.168.1.1 --count 5
# Current: 192.168.1.1
# Next 1: 192.168.1.2
# Next 2: 192.168.1.3
# Next 3: 192.168.1.4
# Next 4: 192.168.1.5
# Next 5: 192.168.1.6Options:
-n, --count <number>- Get N next IP addresses (1-100)
Get the previous IP address in sequence.
ipnav previous 192.168.1.10
# Prev 1: 192.168.1.9
# Current: 192.168.1.10
ipnav prev 192.168.1.10 --count 3
# Prev 3: 192.168.1.7
# Prev 2: 192.168.1.8
# Prev 1: 192.168.1.9
# Current: 192.168.1.10Options:
-n, --count <number>- Get N previous IP addresses (1-100)
Generate all IP addresses between start and end (inclusive).
ipnav range 192.168.1.1 192.168.1.5
# π IP Range (5 addresses):
# 1. 192.168.1.1
# 2. 192.168.1.2
# 3. 192.168.1.3
# 4. 192.168.1.4
# 5. 192.168.1.5
ipnav range 192.168.1.1 192.168.1.255 --count
# π IP Range Information:
# ββββββββββββββββββββββββββββββββββββββββ
# Start: 192.168.1.1
# End: 192.168.1.255
# Count: 255 addresses
# ββββββββββββββββββββββββββββββββββββββββOptions:
-c, --count- Only show the count of IPs in range-l, --limit <number>- Limit output to specified number of IPs (default: 100)
Compare two IP addresses numerically.
ipnav compare 192.168.1.1 192.168.1.2
# π’ IP Comparison:
# ββββββββββββββββββββββββββββββββββββββββ
# IP 1: 192.168.1.1
# IP 2: 192.168.1.2
# Result: 192.168.1.1 < 192.168.1.2 (IP 1 is smaller)
# ββββββββββββββββββββββββββββββββββββββββ| Command | Alias | Description |
|---|---|---|
validate-ip |
vip |
Validate IPv4 address |
validate-mask |
vmask |
Validate subnet mask |
validate-cidr |
vcidr |
Validate CIDR notation |
validate-batch |
vbatch |
Validate multiple IPs |
to-binary |
bin |
Convert IP to binary |
from-binary |
fbin |
Convert binary to IP |
to-integer |
int |
Convert IP to integer |
from-integer |
fint |
Convert integer to IP |
cidr-to-mask |
c2m |
Convert CIDR to subnet mask |
mask-to-cidr |
m2c |
Convert subnet mask to CIDR |
convert |
cvt |
Show all IP representations |
subnet-info |
sinfo |
Get subnet information |
network-address |
netaddr |
Calculate network address |
broadcast-address |
bcast |
Calculate broadcast address |
in-subnet |
insubnet |
Check subnet membership |
classify |
class |
Classify as public/private |
next |
- | Get next IP address |
previous |
prev |
Get previous IP address |
range |
- | Generate IP range |
compare |
cmp |
Compare two IPs |
# Check if a host is in your network
ipnav in-subnet 192.168.1.50 192.168.1.0 255.255.255.0
# Get available hosts in a subnet
ipnav subnet-info 192.168.1.0 --cidr 24
# Find network and broadcast addresses
ipnav network-address 10.0.50.100 255.255.255.0
ipnav broadcast-address 10.0.50.100 255.255.255.0# Check if an IP is public (external) or private (internal)
ipnav classify 203.0.113.45
# Validate a list of IPs from a file
cat ip_list.txt | xargs ipnav validate-batch --quiet# Generate test IP addresses
ipnav range 192.168.1.1 192.168.1.10
# Convert IPs for different formats
ipnav convert 172.16.0.1
# Get sequential IPs for testing
ipnav next 10.0.0.1 --count 5# Understand subnet calculations
ipnav subnet-info 192.168.1.100 255.255.255.0
# See all representations of an IP
ipnav convert 8.8.8.8
# Convert between CIDR and subnet mask
ipnav cidr-to-mask 24
ipnav mask-to-cidr 255.255.0.00- Success1- Error (invalid input, validation failure, etc.)
This makes the CLI perfect for use in shell scripts:
#!/bin/bash
if ipnav validate-ip "$1"; then
echo "Valid IP, proceeding..."
else
echo "Invalid IP, aborting!"
exit 1
fiipnav vip 192.168.1.1 # Instead of validate-ip
ipnav bin 10.0.0.1 # Instead of to-binary
ipnav cvt 172.16.0.1 # Instead of convert# Validate IPs from a file
cat servers.txt | xargs ipnav validate-batch
# Process multiple conversions
echo "192.168.1.1 10.0.0.1" | xargs -n1 ipnav to-integer# Extract IPs from logs and validate them
grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' access.log | \
sort -u | \
xargs ipnav validate-batch- Node.js 14.x or higher
- ip-navigator - Core IP address operations
- commander - CLI framework
- ip-navigator - The core library powering this CLI
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Marc Tyson CLEBERT [email protected]
- Website: marctysonclebert.com
- GitHub: @clebertmarctyson
- Twitter/X: @ClebertTyson
- Buy me a coffee: Support my work
If ip-navigator-cli has been helpful to you, consider:
- β Starring the repo
- π Reporting bugs
- π‘ Suggesting features
- β Buying me a coffee
Made with β€οΈ using ip-navigator
