reusing generate_ipaddr smartly.