Prevent adding undefined IP address to the hosts list

This should fix 1/2 of issue #206