[removed] Is IP In One Of These Subnets?

前端 未结 6 503
独厮守ぢ
独厮守ぢ 2021-01-30 23:26

So I have ~12600 subnets:

eg. 123.123.208.0/20

and an IP.

I can use a SQLite Database or an array or whatever

There was a similar question asked

6条回答
  •  醉话见心
    2021-01-31 00:01

    Functions IPnumber and IPmask are nice, however I would rather test like:

    (IPnumber('123.123.49.123') & IPmask('22')) == (IPnumber('123.123.48.0')  & IPmask('22'))
    

    Because for each address, you only need to take into account the network part of the address. Hence doing IPmask('22') will zero-out the computer part of the address and you should do the same with the network address.

提交回复
热议问题