Skip to content

Add is private/public method #7

@mhf-ir

Description

@mhf-ir

Add is private method:

ip:isPrivate("127.0.0.1")
ip:isPrivateV4("127.0.0.1")
ip:isPrivateV6("fd12:3456:789a:1::1")

ip:isPublic("8.8.8.8")
ip:isPublicV4("8.8.8.8")
ip:isPublicV6("2400:cb00::/32")

https://en.wikipedia.org/wiki/Private_network

RFC1918 name IP address range Number of addresses Largest CIDR block (subnet mask) Host ID size Mask bits Classful description
24-bit block 10.0.0.0 – 10.255.255.255 16777216 10.0.0.0/8 (255.0.0.0) 24 bits 8 bits single class A network
20-bit block 172.16.0.0 – 172.31.255.255 1048576 172.16.0.0/12 (255.240.0.0) 20 bits 12 bits 16 contiguous class B networks
16-bit block 192.168.0.0 – 192.168.255.255 65536 192.168.0.0/16 (255.255.0.0) 16 bits 16 bits 256 contiguous class C networks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions