Test gateway before host if gateway is defined.