How to force web server IP for an HTTP request (python example)

The easiest way to specify an http server IP address, when you want to FORCE a request to a specific server, is to make the http request to that IP, then just include the Host header.

This is not immediately obvious if you do not have some knowledge of the http protocol.

Here is how you do it with the requests library in python:

import requests
url = ‘http://IP_GOES_HERE/’
headers = {‘Host’:’www.EXAMPLE.net’}
r = requests.get(url,headers=headers)

In the above example, the http request will go to server IP_GOES_HERE, and ask for the www.EXAMPLE.net website, using GET.

Basicly, is the same as http://www.example.net …. if the A record in the DNS was IP_GOES_HERE

Acerca de Buanzo

Io que se!
Esta entrada fue publicada en General. Guarda el enlace permanente.