OVH Community, your new community space.

ip size of network in iptables


ramcom
09-02-2015, 15:09
thank you much
its very clear now for me

alvaroag
09-02-2015, 12:20
It's all about binary. First, put the IP addresses in binary notation, each part as a single byte

Code:
5.23.128.0   = 00000101 00010111 10000000 00000000
5.23.255.255 = 00000101 00010111 11111111 11111111
               ======== ======== =
Now, having both IPs in binary notation, you count the number of bits that are the same on both IPs, from left to right: 17. That's the CIDR mask, so your network is 5.23.128.0/17.

To get the number of IPs in such network, solve (2 ^ (32 - 17) ) - 1. Note that the number of usable IPs is two less than that.

ramcom
09-02-2015, 09:07
Thanks for reply
could i ask how do you come to 17?
first 2 byte is 16 third byte begins from 128 to 255 is 1??? 16+1=17

heise
09-02-2015, 08:40
5.23.128.0/17

ramcom
09-02-2015, 08:21
Hello everyone

From IP To IP Total IPs
5.23.128.0 5.23.255.255 32768

what is size of network in example above?

I think it is 5.23.128.0/20 ??? i'm not sure

i'm gonna use in iptables
-A INPUT -s 5.23.128.0/20 -p tcp -m tcp --dport 22 -j ACCEPT

annyone a suggestions?

thanks by advance