Last active
          May 31, 2024 13:07 
        
      - 
      
- 
        Save JohnLBevan/ec7a830e41e43a6a0b5db9d053e08041 to your computer and use it in GitHub Desktop. 
Revisions
- 
        JohnLBevan renamed this gist May 31, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        JohnLBevan created this gist May 31, 2024 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ Row 1 has headings: - CIDR - IP - First IP Int - Last IP Int - Test IP Int - IP In Range Column A contains CIDRs (e.g. `3.2.1.0/30`) Column B contains IPs (e.g. `3.2.1.2`) Column C contains a formula to calculate the first IP in the CIDR: `=INDEX(TEXTSPLIT($A2, "."), 1) * 256^3 + INDEX(TEXTSPLIT($A2, "."), 2) * 256^2 + INDEX(TEXTSPLIT($A2, "."), 3) * 256 + INDEX(TEXTSPLIT($A2, {".","/"}), 4)` Column D contains a formula to calculate the last IP in the CIDR: `=C2 + POWER(2,32-INDEX(TEXTSPLIT($A2, {".","/"}), 5)) - 1` Column E contains a forumla to calculate the IP: `=INDEX(TEXTSPLIT(B2, "."), 1) * 256^3 + INDEX(TEXTSPLIT(B2, "."), 2) * 256^2 + INDEX(TEXTSPLIT(B2, "."), 3) * 256 + INDEX(TEXTSPLIT(B2, "."), 4)` Column F checks whether the IP in column B is in the CIDR from column A: `=AND($E2>=$C2,$E2<=$D2)`