You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I have found a logical error in iptools.
Iptools validate_range does not see the errors in network/netmask pair.
write
> iptools::validate_range("10.0.0.0/8")
[1] TRUE
wrong
> iptools::validate_range("10.0.1.0/8")
[1] TRUE
I am working with ip networks and i know that 10.0.1.0/8 is not a valid network.
10.0.1.0 is ip address that is part of 10.0.0.0/8 network. Next /8 network will be 11.0.0.0/8.
10.0.1.0 can be /24 or smaller network only.
You can see, that maximum_ip is the same (which is correct), but minimum ip on 10.0.1.0/8 is 10.0.1.0 which is wrong for /8 network.
range_boundaries("10.0.1.0/8"), how i see it, should have one of two option:
It should tell you that your network is wrong and tell you, that probably your network is "10.0.0.0/8"
It should calculate minimum_ip based on probably network.
You can calculate probably network by conjuction ip on netmask (like network devices do it) or by devision on hosts per subnet. Actually i had to do something like this. I made named vector of usable ips and netmask as name. Like this:
Than i check remainder of devision first ip of network and ip's for that network
> numeric_ip %% ips_for_network
[1] 0
If it's equal to zero, everything is fine, if not - you should subtract remainder from numeric_ip and transform result to ip. This will be your network address. Example with uncorrect network is below:
> network <- "10.0.1.0/8"
> network
[1] "10.0.1.0/8"
> netmask_ip_vector[[gsub(pattern = "^.*(/.*$)", replacement = "\\1", x = network)]] -> ips_for_network
> ips_for_network # ips_for_network is the same as 10.0.0.0/8
[1] 16777216
> gsub(pattern = "/.*$", replacement = "", x = network) %>% ip_to_numeric() -> numeric_ip
> numeric_ip # different from 10.0.0.0/8
[1] 167772416
> numeric_ip %% ips_for_network -> remainder
> remainder # not equal to zero, so the network part is uncorrect to /8 netmask
[1] 256
> currect_network <- (numeric_ip - remainder) %>% numeric_to_ip()
> currect_network
[1] "10.0.0.0"
Using this logic or something similar you can make your library more usefull.
Sorry for many letters and my English.
Best Regards, Konstantin.
P.S.
Have found another problem with validate_range function
Hello!
I have found a logical error in iptools.
Iptools validate_range does not see the errors in network/netmask pair.
write
wrong
I am working with ip networks and i know that 10.0.1.0/8 is not a valid network.
10.0.1.0 is ip address that is part of 10.0.0.0/8 network. Next /8 network will be 11.0.0.0/8.
10.0.1.0 can be /24 or smaller network only.
Also it affects range_boundaries function:
write
wrong
You can see, that maximum_ip is the same (which is correct), but minimum ip on 10.0.1.0/8 is 10.0.1.0 which is wrong for /8 network.
range_boundaries("10.0.1.0/8"), how i see it, should have one of two option:
You can calculate probably network by conjuction ip on netmask (like network devices do it) or by devision on hosts per subnet. Actually i had to do something like this. I made named vector of usable ips and netmask as name. Like this:
Than i calculate numeric value of first ip of that network (with cutting network part)
Than i check how many ips should be in that network (using my vector)
Than i check remainder of devision first ip of network and ip's for that network
If it's equal to zero, everything is fine, if not - you should subtract remainder from numeric_ip and transform result to ip. This will be your network address. Example with uncorrect network is below:
Using this logic or something similar you can make your library more usefull.
Sorry for many letters and my English.
Best Regards, Konstantin.
P.S.
Have found another problem with validate_range function
4,545645764567 is also not valid netmask.
The text was updated successfully, but these errors were encountered: