Use hostname -I in ipdetect script