Remove some code duplication for guessing IP addresses.