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

Chris Angelico rosuav at gmail.com
Wed Oct 2 02:28:40 EDT 2019


On Wed, Oct 2, 2019 at 2:31 PM Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
>
> Hi,
>
> See my following test:
>
> With ipython:
>
> In [1]: import
> socket
>
> In [2]: socket.gethostbyname
> ('www.vpngate.net')
> Out[2]: '130.158.75.44'
>
>
> With dig:
>
> $ dig www.vpngate.net @114.114.114.114 +short
> 31.13.65.1
> $ dig www.vpngate.net @8.8.8.8 +short
> 46.82.174.68
>
> Any hints?

When you ask dig, you are always asking for a DNS lookup. But
gethostbyname does a lot of other things too. My guess is that your
/etc/hosts has an entry for that domain. It's also possible that your
DNS resolver is misconfigured, especially since the authoritative
servers for that domain disagree with your dig results.

ChrisA



More information about the Python-list mailing list