Use getent rather than dig for hostname resolution

`dig` may not be installed on a host system, but `getent` is a core command.