0
dig www.sina.com.cn
jupiter.sina.com.cn.        30      IN      A       183.232.24.117
jupiter.sina.com.cn.        30      IN      A       183.232.24.115
jupiter.sina.com.cn.        30      IN      A       183.232.24.112
jupiter.sina.com.cn.        30      IN      A       183.232.24.114
jupiter.sina.com.cn.        30      IN      A       183.232.24.111
jupiter.sina.com.cn.        30      IN      A       183.232.24.113
jupiter.sina.com.cn.        30      IN      A       183.232.24.116

It means that the domain www.sina.com.cn can be parsed as one of seven ips as above.

I want to know which ip is exactly to be visited for the following codes.

import requests
source = 'http://www.sina.com.cn'
r = requests.get(source)
print(r.headers)

{'Server': 'nginx', 'Expires': 'Fri, 03 Feb 2017 06:41:23 GMT', 'Date': 'Fri, 03 Feb 2017 06:40:23 GMT', 'Age': '10', 'Content-Encoding': 'gzip', 'Content-Length': '133766', 'Content-Type': 'text/html', 'X-Cache': 'HIT from cmnet.xxg.18a4.34.spool.sina.com.cn', 'X-Powered-By': 'shci_v1.03', 'Vary': 'Accept-Encoding', 'Cache-Control': 'max-age=60', 'Last-Modified': 'Fri, 03 Feb 2017 06:40:00 GMT'}

There is no ip address info.

ping  cmnet.xxg.18a4.34.spool.sina.com.cn
ping: unknown host cmnet.xxg.18a4.34.spool.sina.com.cn

Which ip address is being visited when to send a request to domain name www.sina.com.cn with above python codes? To open wireshark to monitor the process.

enter image description here

At this time www.sina.com.cn is parsed into 183.232.24.111,maybe next time it may be parsed into 183.232.24.117,no matter which one,i want it to be displayed by my python codes.

enter image description here

The ip will be changed from one into other in the range (183.232.24.111-183.232.24.117).

showkey
  • 482
  • 42
  • 140
  • 295
  • You see a round robin DNS setup that *intentionally* returns one IP address out of a pool. This is used mainly for load balancing and fail over. Also there is a reverse proxy involved for the same reasons. All of that does not really matter to the user and most likely also not to you. – Klaus D. Feb 03 '17 at 07:29

1 Answers1

1
>>> import requests
>>> r = requests.get('http://www.sina.com.cn', stream=True)
>>> r.raw._connection.sock.getpeername()
('151.249.91.56', 80)

Body Content Workflow

more

Community
  • 1
  • 1
Eugene Lisitsky
  • 12,113
  • 5
  • 38
  • 59