Search code examples
ipexim

What is the syntax format for a range of IPv4 addresses called and how does it work?


All IP's mentioned here are IPv4

General Concept Confusion

I am trying to use a system which asks for a set of IP addresses, and offers me the example format of 192.168.0.0/24 to enter sets of IP addresses... but I don't understand what that format implies nor what it is called.

Because the exampled format is an IP address, webs searching for this information is very muddy and hard to find anything useful.

Documentation:

You can use the following formats:

Single IP addresses — Example: 192.168.0.1
A range of IP addresses — Example: 192.168.0.0/24

Specifically, I don't understand the /24 on the IP address syntax; I understand this is a "block" of 24 but considering that there seems to be many more than 24 possible IPs from - for example - 192.168.0.-- then I don't get the importance of the /24; is this a maximum? Can /255 work, as that seems the actual number of possible values [in a block]? Does the /24 only apply to the "final" block or does it apply to any block with value of 0?

My Specific Issue

I have a set of IP addresses I need the system to "catch"/recognise. The IPs to catch have the first two blocks are always the same, and the final two blocks can be anything.

For example:

I want to catch ALL of the below:

145.178.12.145
145.178.98.165
145.178.10.123
...
...
145.178.10.255

But I do NOT want to catch

145.179.124.35
27.49.35.121

Only catching IPs that begin 145.178........ ; how can I do this with the /24 formatting given above?

The set is


Solution

  • This is the explanation of the / in the IP.

    About Slash Notation

    Many things use slash notation, also known as CIDR (Classless Inter-Domain Routing) notation, for many purposes, such as policy configuration. You use slash notation differently for IPv4 and IPv6 addresses.

    IPv4

    Slash notation is a compact way to show or write an IPv4 subnet mask. When you use slash notation, you write the IP address, a forward slash (/), and the subnet mask number.

    To find the subnet mask number:

    Convert the decimal representation of the subnet mask to a binary representation.
    Count each “1” in the subnet mask. The total is the subnet mask number.
    

    For example, to write the IPv4 address 192.168.42.23 with a subnet mask of 255.255.255.0 in slash notation:

    Convert the subnet mask to binary.<br>
    In this example, the binary representation of 255.255.255.0 is:<Br>
    11111111.11111111.11111111.00000000.<Br>
    Count each 1 in the subnet mask.<br>
    In this example, there are twenty-four (24).<br>
    Write the original IP address, a forward slash (/), and then the number from Step 2.<br>
    The result is 192.168.42.23/24.<br>
    

    This table shows common network masks and their equivalents in slash notation.

    Network Mask    Slash Equivalent
    255.0.0.0           /8
    255.255.0.0         /16
    255.255.255.0       /24
    255.255.255.128     /25
    255.255.255.192     /26
    255.255.255.224     /27
    255.255.255.240     /28
    255.255.255.248     /29
    255.255.255.252     /30
    255.255.255.254     /31
    255.255.255.255     /32
    

    To solve your problem, 145.178.0.0/16 will catch all the IPs from 145.178.0.0 to 145.178.255.255.