ipv4-subnet-calculator-php
ipv4-subnet-calculator-php copied to clipboard
Request: calculate n-th subnet
Hi,
Would it be possible to add to the code an n- subnet value. For example the bc, hostmin, hostmax, etc of the 3th subnet for 123.78.88.90/12 ? Maybe feeding it as an argument to the script?
Thnx. Jay
Hi, Thanks for your interest in improving the IPv4 SubnetCalculator.
Can you provide some examples to make it clear what you are describing?
Thanks.
Hi Mark, Thanks for replying. For example when i ask what is the seventh subnet for 172.68.78.89/18 i need to find the first netaddress so i can increment from there 7 Times with (256-(32-cidr))
Amy ideas Tia.
Op 22 dec. 2017 16:28 schreef "Mark Rogoyski" [email protected]:
Hi, Thanks for your interest in improving the IPv4 SubnetCalculator.
Can you provide some examples to make it clear what you are describing?
Thanks.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markrogoyski/ipv4-subnet-calculator-php/issues/6#issuecomment-353619405, or mute the thread https://github.com/notifications/unsubscribe-auth/AhJBzVSz8iEh1f4t8OHp3Vvw9Nm3nMbpks5tC8qVgaJpZM4RKMRu .
Hi,
When you specify a 172.68.78.89/18 network, the addressable IP range is 172.68.64.0–172.68.127.255. Therefore, when you say you want the seventh subnet, what specifically are you looking for?
Any clarification and specific examples would help. Thanks!
Hi Mark,
Thanks again. Let me take a class c address as An example. Say I have a question like "what is the 3th subnet for 192.168.11.30/29 Now we have n to the power of (32-29) = 8 So our increment is in steps of 8. So: Subnet 1 net address: 192.168.11.0 Subnet 2 net address: 192.168.11.8 Subnet 3 net address: 192.168.11.16 Subnet 4 net address: 192.168.11.24
Where Subnet 3 has a net address of 192.168.11.16, a broadcast of 192.168.11.23 and hostmin of 192.168.11.17 - 192.168.11-22
Is there a way to feed this network number (3) as an argument? Currently I translated the netID to binary. Then I loop through each group in the string of 32 chars hereby counting until 8 (if(counter == 8), until 16, 24 and 32. I than put each bitgroup of 8 in an array. Then I loop through the array and check (strpos) array indexes [0], [1], [2] and [3] if there is a 0 in the string of 8 bits. If there is, I know it is no longer part of the network, so it must be the host portion. I then take the decimal original IP address and use each octet 1:1 where all bits are 1 (so it must be decimal 255, thus network portion). The array index where a zero occurs is replaced by a zero. It works, but I do not think it is efficient. Is there a way to use this in your script using regexp maybe? I'm not really an expert on regex so maybe you have a simpler way to do tghis?
Thansk again and sorry for bothering you like this.
Greets,
Hans
Op 22 dec. 2017 18:33 schreef "Mark Rogoyski" [email protected]:
Hi,
When you specify a 172.68.78.89/18 network, the addressable IP range is 172.68.64.0–172.68.127.255. Therefore, when you say you want the seventh subnet, what specifically are you looking for?
Any clarification and specific examples would help. Thanks!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markrogoyski/ipv4-subnet-calculator-php/issues/6#issuecomment-353642985, or mute the thread https://github.com/notifications/unsubscribe-auth/AhJBzef6MGxUHzikRiNS9y52n_5bZKo_ks5tC-fmgaJpZM4RKMRu .
192.168.11.30/29 would have an addressable IP range of 192.168.11.24 - 192.168.11.31. How do you come up with your subnets 1, 2, and 3?
Hi Mark,
Yes for the given subnet indeed it is. But in this range counting up from the first possible network (which is what im looking for) IT increments in steps of 8. This means the given ip is in the 3th network starting from the first possible network. This 3th network ranges indeed from 192.168.11.24-31 where 192.168.11.32 would be the net address for the next subnet. This is a typical Cisco question and my implementation of your script generates such Questions.
I hope this clarifies it a bit? Greetz Hans
Op 22 dec. 2017 20:05 schreef "Mark Rogoyski" [email protected]:
192.168.11.30/29 would have an addressable IP range of 192.168.11.24 - 192.168.11.31. How do you come up with your subnets 1, 2, and 3?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markrogoyski/ipv4-subnet-calculator-php/issues/6#issuecomment-353657778, or mute the thread https://github.com/notifications/unsubscribe-auth/AhJBzTXSQ6uB-lO1RRNgZFPiRn37XmxQks5tC_13gaJpZM4RKMRu .
That would have been the fourth network, not the third. Sorry:-)
Op 22 dec. 2017 20:20 schreef "Hans Kamerling" [email protected]:
Hi Mark,
Yes for the given subnet indeed it is. But in this range counting up from the first possible network (which is what im looking for) IT increments in steps of 8. This means the given ip is in the 3th network starting from the first possible network. This 3th network ranges indeed from 192.168.11.24-31 where 192.168.11.32 would be the net address for the next subnet. This is a typical Cisco question and my implementation of your script generates such Questions.
I hope this clarifies it a bit? Greetz Hans
Op 22 dec. 2017 20:05 schreef "Mark Rogoyski" [email protected]:
192.168.11.30/29 would have an addressable IP range of 192.168.11.24 - 192.168.11.31. How do you come up with your subnets 1, 2, and 3?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markrogoyski/ipv4-subnet-calculator-php/issues/6#issuecomment-353657778, or mute the thread https://github.com/notifications/unsubscribe-auth/AhJBzTXSQ6uB-lO1RRNgZFPiRn37XmxQks5tC_13gaJpZM4RKMRu .
+1 this would be a great feature. E.g. if I want to further subnet the a /24 network into /28, it would be nice to have these generated.
Hi @agwidarsito,
Thank you for your feedback above this feature.
Do you know if there are any similar tools or software packages that have similar functionality? It would help to determine how to name the functionality and to verify correctness of an implementation.
Thanks, Mark