python socket dns query will get the correct result while the dig will not.

Chris Angelico rosuav at gmail.com
Wed Oct 2 02:45:55 EDT 2019


On Wed, Oct 2, 2019 at 4:41 PM Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
>
> On Wed, 02 Oct 2019 16:28:40 +1000, Chris Angelico wrote:
>
> > When you ask dig, you are always asking for a DNS lookup. But
> > gethostbyname does a lot of other things too.
>
> What other things, could you please give more detailed hints?

Start with /etc/nsswitch.conf and see how far down the rabbit hole you
want to go...

http://man7.org/linux/man-pages/man5/nsswitch.conf.5.html

> > My guess is that your
> > /etc/hosts has an entry for that domain.
>
> No.
>
> > It's also possible that your
> > DNS resolver is misconfigured, especially since the authoritative
> > servers for that domain disagree with your dig results.
>
> As you can see, I use the public dns servers for the dig, and I cannot do
> any config on these dns resolvers.
>

Actually I'm not sure that you are, since you're getting completely
different results to mine. It's possible you have something
intercepting your DNS requests.

Hmm. The first IP you posted (which purportedly came back from
114.114.114.114) belongs to Facebook. That's pretty suspicious.

ChrisA



More information about the Python-list mailing list