Swap lookup4/lookup6 in place of lookup.  Remove 'localhost' special case.
I'm still not happy.  This ignores /etc/hosts.