{"id":13994561,"url":"https://github.com/nicholaschiasson/fcidr","last_synced_at":"2026-02-11T04:03:09.439Z","repository":{"id":178726379,"uuid":"662232160","full_name":"nicholaschiasson/fcidr","owner":"nicholaschiasson","description":"Fragmented Classless Inter-Domain Routing (FCIDR)","archived":false,"fork":false,"pushed_at":"2023-11-13T17:08:25.000Z","size":41,"stargazers_count":16,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T19:08:18.948Z","etag":null,"topics":["cidr","cidr-calculator","cidr-list","cli","ip","ipv4","network","networking"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholaschiasson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"open_collective":"nicholaschiasson","ko_fi":"nicholaschiasson","liberapay":"nicholaschiasson","issuehunt":"nicholaschiasson"}},"created_at":"2023-07-04T16:40:24.000Z","updated_at":"2024-06-27T11:27:56.000Z","dependencies_parsed_at":"2024-01-18T05:10:26.608Z","dependency_job_id":"b6f4b718-0b60-46e4-b3b7-e29db6cf563c","html_url":"https://github.com/nicholaschiasson/fcidr","commit_stats":null,"previous_names":["nicholaschiasson/fcidr"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/nicholaschiasson/fcidr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaschiasson%2Ffcidr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaschiasson%2Ffcidr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaschiasson%2Ffcidr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaschiasson%2Ffcidr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholaschiasson","download_url":"https://codeload.github.com/nicholaschiasson/fcidr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaschiasson%2Ffcidr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29326839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T03:52:29.695Z","status":"ssl_error","status_checked_at":"2026-02-11T03:52:23.094Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","cidr-calculator","cidr-list","cli","ip","ipv4","network","networking"],"created_at":"2024-08-09T14:02:56.877Z","updated_at":"2026-02-11T04:03:09.434Z","avatar_url":"https://github.com/nicholaschiasson.png","language":"Rust","funding_links":["https://opencollective.com/nicholaschiasson","https://ko-fi.com/nicholaschiasson","https://liberapay.com/nicholaschiasson","https://issuehunt.io/r/nicholaschiasson"],"categories":["Rust"],"sub_categories":[],"readme":"# fcidr\n\n[![crates.io](https://img.shields.io/crates/v/fcidr)](https://crates.io/crates/fcidr)\n\nFragmented Classless Inter-Domain Routing (FCIDR)\n\nA library exposing a data structure to represent a set of CIDR ranges as well\nas an interface to compute set operations over CIDRs.\n\nThis data structure can be applied, for example, in configuring firewalls that\n*implicitly deny* (AWS Security Groups) using a rule set that explicitly\nexpresses rules for both allow and deny.\n\n\u003e **Note**\n\u003e Currently, only IPv4 is supported. IPv6 support is tracked by [#6](https://github.com/nicholaschiasson/fcidr/issues/6).\n\n## CLI\n\nThis project also publishes a binary application for use on the command line to\nsupport composing chains of set operations on CIDRs by reading from standard\ninput.\n\n### Installation\n\nFor now, crates.io is the only place this is being distributed.\n\n```\ncargo install fcidr\n```\n\n### Usage\n\n```\nFragmented Classless Inter-Domain Routing (FCIDR)\n\nUsage: fcidr [CIDR] \u003cCOMMAND\u003e\n\nCommands:\n  complement  Compute the complement of the input CIDR(s) [aliases: !, not]\n  difference  Compute the set difference between the input CIDR(s) and another CIDR [aliases: -, exclude, minus]\n  superset    Exits successfully if the input CIDR(s) is a superset of another CIDR [aliases: \u003e, contains]\n  union       Compute the set union of the input CIDR(s) and another CIDR [aliases: +, include, plus]\n  help        Print this message or the help of the given subcommand(s)\n\nArguments:\n  [CIDR]  The input CIDR range and first operand to the computation. If omitted, input is taken from stdin. In this way, multiple computations can be chained together\n\nOptions:\n  -h, --help     Print help\n  -V, --version  Print version`\n```\n\n### Examples\n\n#### Computing a specific set of CIDRs within 10.0.0.0/8, excluding some subranges, and including a subrange of one that was excluded\n\n```\nfcidr 10.0.0.0/8 difference 10.0.64.0/20 | fcidr difference 10.0.82.0/24 | fcidr union 10.0.82.74/31\n10.0.0.0/18\n10.0.80.0/23\n10.0.82.74/31\n10.0.83.0/24\n10.0.84.0/22\n10.0.88.0/21\n10.0.96.0/19\n10.0.128.0/17\n10.1.0.0/16\n10.2.0.0/15\n10.4.0.0/14\n10.8.0.0/13\n10.16.0.0/12\n10.32.0.0/11\n10.64.0.0/10\n10.128.0.0/9\n```\n\n#### Inverting the previous result\n\n```\nfcidr 10.0.0.0/8 difference 10.0.64.0/20 | fcidr difference 10.0.82.0/24 | fcidr union 10.0.82.74/31 | fcidr complement\n0.0.0.0/5\n8.0.0.0/7\n10.0.64.0/20\n10.0.82.0/26\n10.0.82.64/29\n10.0.82.72/31\n10.0.82.76/30\n10.0.82.80/28\n10.0.82.96/27\n10.0.82.128/25\n11.0.0.0/8\n12.0.0.0/6\n16.0.0.0/4\n32.0.0.0/3\n64.0.0.0/2\n128.0.0.0/1\n```\n\n#### Alternative concise syntax\n\nNote these symbols may not play nice with your shell, so you can quote them if you want, for example `fcidr \"!\"`).\n\n```\nfcidr 10.0.0.0/8 + 127.0.0.0/16 | fcidr - 10.64.0.0/16 | fcidr !\n0.0.0.0/5\n8.0.0.0/7\n10.64.0.0/16\n11.0.0.0/8\n12.0.0.0/6\n16.0.0.0/4\n32.0.0.0/3\n64.0.0.0/3\n96.0.0.0/4\n112.0.0.0/5\n120.0.0.0/6\n124.0.0.0/7\n126.0.0.0/8\n127.1.0.0/16\n127.2.0.0/15\n127.4.0.0/14\n127.8.0.0/13\n127.16.0.0/12\n127.32.0.0/11\n127.64.0.0/10\n127.128.0.0/9\n128.0.0.0/1\n```\n\n#### Check if an IP is within a CIDR\n\n```\nfcidr 255.0.0.0/16 contains \"255.0.1.2/32\" \u0026\u0026 echo Woohoo!\nWoohoo!\n```\n\n```\necho 255.0.0.0/16 | fcidr contains \"255.1.1.2/32\" \u0026\u0026 echo Woohoo!\nError: \"not a superset of 255.1.1.2/32\"\n```\n\n#### Check if a CIDR is within any of a large set of CIDRs\n\nExpanding upon the previous example, thanks to Amazon publishing a JSON formatted list of their public IP ranges, we can check if an IP or CIDR effectively is owned by Amazon. As long as we can get the list of ranges separated by new lines, piping that to `fcidr` makes the task trivial.\n\n```\ncurl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | fcidr contains 52.43.76.84/30 \u0026\u0026 echo \"This CIDR is within an Amazon range.\"\nThis CIDR is within an Amazon range.\n```\n\n```\ncurl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | fcidr contains 62.43.76.0/24 \u0026\u0026 echo \"This CIDR is within an Amazon range.\"\nError: \"not a superset of 62.43.76.0/24\"\n```\n\n## Development\n\n### Prerequisites\n\n- [mise](https://mise.jdx.dev/)\n\n### How-to\n\nInstall tooling. Necessary to run all other commands.\n\n```shell\nmise install\n```\n\nBuild with cargo.\n\n```shell\njust build\n```\n\nCheck the code with cargo's built-in fast static analysis.\n\n```shell\njust check\n```\n\nRemove build files.\n\n```shell\njust clean\n```\n\nFormat the code.\n\n```shell\njust format\n```\n\nCheck the code with clippy for better static analysis.\n\n```shell\njust lint\n```\n\nRun the application.\n\n```shell\njust run\n```\n\nRun tests with cargo's built-in test runner.\n\n```shell\njust test\n```\n\nWatch for code changes and rebuild.\n\n```shell\njust watch\n```\n\nAll `just` commands can accept additional command line arguments after a `--`.\n\nFor example: run the application with a flag to report the version.\n\n```shell\njust run -- --version\n```\n\n#### Tips and Recommendations\n\n##### Open IDE from Development Shell\n\nTo get linking to rust binaries in your IDE, you should open the development shell from your terminal and then open your IDE\nfrom that shell session. This will carry over the development shell's environment into your IDE.\n\nFor example if you work with VSCode.\n\n```shell\ncd path/to/this/project\nnix develop\ncode .\n```\n\nBy doing this, you can install the rust-analyzer VSCode extension and it will work properly since it will be able to point to\nthe correct rust binaries and libraries. You will also have access in VSCode to any packages installed by the nix flake.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaschiasson%2Ffcidr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholaschiasson%2Ffcidr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaschiasson%2Ffcidr/lists"}