github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/cidr.en.md (about) 1 ### `cidr()` {#fn-cidr} 2 3 Function prototype: `fn cidr(ip: str, prefix: str) bool` 4 5 Function description: Determine whether the IP is in a CIDR block 6 7 Function parameters: 8 9 - `ip`: IP address 10 - `prefix`: IP prefix, such as `192.0.2.1/24` 11 12 Example: 13 14 ```python 15 # script 16 ip = "192.0.2.233" 17 if cidr(ip, "192.0.2.1/24") { 18 add_key(ip_prefix, "192.0.2.1/24") 19 } 20 21 # result 22 { 23 "ip_prefix": "192.0.2.1/24" 24 } 25 ```