Remove some duplication from flush_dns