Well, while this may be the DB forum, if you're happy (and it's practical) to do the sorting once it has been retrieved to your PHP script then take a look at usort [uk3.php.net] and code a custom dotted number comparison that compares them segment by segment.
Whether this is practical is going to depend on volume though.
Otherwise you may have to impose certain restrictions on what you store. For example, it's not uncommon to hexify IP address to an 8 "digit" hexadecimal number so that 127.0.0.1 would become 7F000001, 10.1.2.3 => 0A010203 etc. This being possible because you know how many segments and the maximum size of any segment.