I’m storing IP addresses as integers now. There is the handy IPAddr
class which can convert to/from string values. MySQL even has native
functions for this.
Unless your database can support unsigned ints (which are not
accessible using standard migrations), you’ll need to subtract
2147483648 from the value before storing. This converts the unsigned
integer IP address to a signed integer to be stored in the database.
Once you’re storing IP addresses and netmasks as integers rather than
strings, you can do fancy bitwire arithmetic to figure out beginning /
ending IP addresses. It also makes sorting IP addresses much easier.
Hope this helps,