[IPtool] CIDR/IP range conversion and IP matching utility

Being away for about a year now due to lack of time I believe it's the right time to get back into writing.

I wrote a simple utility a while ago to convert CIDR addresses to IP ranges and the other way around (in the C programming language). In addition, it can perform IP matching against CIDR/IP ranges. You can grab the utility here.

Compile the code with:

gcc -DNDEBUG -Wall -W -O2 iptool.c -o iptool

Expand a CIDR address to an IP range:

# ./iptool range 212.251/17
212.251.0.0 - 212.251.127.255

Convert an IP range to a CIDR address:

# ./iptool cidr 212.251.0.0 212.251.127.255
212.251.0.0/17

Match a single IP address against a CIDR address:

# ./iptool cmatch 212.251.0.0/17 212.251.31.59
IP match

Match a single IP address against an IP range:

# ./iptool rmatch "212.251.0.0 - 212.251.127.255" 212.251.31.59
IP match

Parts of the source code may come in handy when writing IP related applications/utilities.

Share and Enjoy:
  • Print
  • Digg
  • Facebook
  • Google Bookmarks
  • Twitter

Leave a comment

Your comment