All Projects → 3th1nk → cidr

3th1nk / cidr

Licence: MIT License
golang to calculate CIDR network

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to cidr

ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+315.69%)
Mutual labels:  ipv6, ipv4, cidr
python-iptools
A few useful functions and objects for manipulating ip addresses in python.
Stars: ✭ 68 (+33.33%)
Mutual labels:  ipv6, ipv4, cidr
Aggregator
A stand-alone class implementation of the IPv4+IPv6 IP+CIDR aggregator from CIDRAM.
Stars: ✭ 19 (-62.75%)
Mutual labels:  ipv6, ipv4, cidr
go-inet
A Go library for reading, formatting, sorting, lookup and converting IP-addresses and IP-blocks
Stars: ✭ 14 (-72.55%)
Mutual labels:  ipv6, ipv4
ngx-ip
An Angular network address component (IPv4, IPv6 and MAC)
Stars: ✭ 20 (-60.78%)
Mutual labels:  ipv6, ipv4
ipaddress
Data analysis of IP addresses and networks
Stars: ✭ 20 (-60.78%)
Mutual labels:  ipv6, ipv4
hphr
Halophile Router (a VyOS-based, SaltStack-automated, NetBox-configured router for small provider networks)
Stars: ✭ 39 (-23.53%)
Mutual labels:  ipv6, ipv4
Geolocate-IP-Browser-Extension
A browser extension, which shows you the origin of your IP address.
Stars: ✭ 21 (-58.82%)
Mutual labels:  ipv6, ipv4
IP2Location-PHP-Module
This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (+201.96%)
Mutual labels:  ipv6, ipv4
6in4
IPv6-in-IPv4 Tunnel Server
Stars: ✭ 133 (+160.78%)
Mutual labels:  ipv6, ipv4
whereabouts
An HTTP service for mapping IPv4 and IPv6 addresses to cities, countries & continents
Stars: ✭ 16 (-68.63%)
Mutual labels:  ipv6, ipv4
ipapi-python
Python bindings for https://ipapi.co (IP Address Location) - Use with python / django / flask for IP address location lookup
Stars: ✭ 42 (-17.65%)
Mutual labels:  ipv6, ipv4
treebitmap
Fast IP lookup table for IPv4/IPv6 prefixes
Stars: ✭ 81 (+58.82%)
Mutual labels:  ipv6, ipv4
bacnet-stack
BACnet Protocol Stack library provides a BACnet application layer, network layer and media access (MAC) layer communications services.
Stars: ✭ 199 (+290.2%)
Mutual labels:  ipv6, ipv4
net-protocol
golang模拟内核协议栈 实现链路层、网络层、传输层、应用层 用户态协议栈 ,基于虚拟网卡TUN/TAP
Stars: ✭ 129 (+152.94%)
Mutual labels:  ipv6, ipv4
Ip
🌏根据IpV4、IpV6地址获取定位信息的PHP🐘组件 PHP components that obtain location information based on IpV4, IpV6 addresses
Stars: ✭ 23 (-54.9%)
Mutual labels:  ipv6, ipv4
freebind
IPv4 and IPv6 address rate limiting evasion tool
Stars: ✭ 88 (+72.55%)
Mutual labels:  ipv6, ipv4
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (-27.45%)
Mutual labels:  ipv6, ipv4
tracetrout
A magical reverse traceroute HTTP(S) server
Stars: ✭ 48 (-5.88%)
Mutual labels:  ipv6, ipv4
go-net-radix
Go bindings for radix tree library for fast subnet (IPv4 and IPv6) lookups
Stars: ✭ 37 (-27.45%)
Mutual labels:  ipv6, ipv4

CIDR

基于Golang net包封装了CIDR网段和IP的常用处理方法

import "github.com/3th1nk/cidr"

举个栗子

c, _ := cidr.ParseCIDR("192.168.1.0/24")
fmt.Println(c.Network())
fmt.Println(c.Broadcast())

start, end := c.IPRange()
fmt.Println(c.IPCount(), start, end)

if err := c.ForEachIP(func(ip string) error {
    // do something
    return nil
}); err != nil {
    fmt.Println(err)
}

网段裂解

# 基于子网数量划分子网段
cs, _ := c.SubNetting(cidr.SUBNETTING_METHOD_SUBNET_NUM, 4)
for _, c := range cs {
    fmt.Println(c.CIDR())
}

# 基于主机数量划分子网段
cs, _ := c.SubNetting(cidr.SUBNETTING_METHOD_HOST_NUM, 64)
for _, c := range cs {
    fmt.Println(c.CIDR())
}

网段合并

c, _ := cidr.SuperNetting([]string{
    "2001:db8::/66",
    "2001:db8:0:0:8000::/66",
    "2001:db8:0:0:4000::/66",
    "2001:db8:0:0:c000::/66",
})
fmt.Println(c.CIDR())
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].