Stub DNS lookups in the tests.

This makes the tests more predictable despite network issues and also
allows the tests to be run offline.