Hướng dẫn dùng cidr converter trong PHP
I have ip and I want to convert it into CIDR block with specific mask (/28, for example). Using PHP. So that input "1.1.1.100" and "28" and output is "1.1.1.96/28"
I found a lot of functions to match and ranges, but nothing about actually converting from ip to CIDR. Seems like to be most basic operation, may be I am missing something, using wrong search terms or misunderstanding masks. For context: I need to block bots, I have their IP and want to block range in ipset. /24 is a bit to much (but easy to make, just replace last bit with ".0/24"), so I want to use /27 /28 /29. asked Feb 29, 2020 at 4:28
QiaoQiao 16.1k28 gold badges86 silver badges117 bronze badges It's ... beautiful
Rolling with this now answered Feb 29, 2020 at 5:17
QiaoQiao 16.1k28 gold badges86 silver badges117 bronze badges Is this what you are looking for ? I searched about it and found this which is close to your output. you can find more information here
Output:
answered Feb 29, 2020 at 5:15
Umer AbbasUmer Abbas 1,7863 gold badges12 silver badges18 bronze badges 1 Not the answer you're looking for? Browse other questions tagged php ip cidr or ask your own question.Conversion table for CIDR notation.
|