Reasons why curl and http request produce different responses

2

I have recently setup a personal website using github pages for hosting and DNS with freenom.

When I make a request using curl:

curl --header "Host: example.com" http://192.30.252.153/

I get the expected response, the HTML from my site, however, when I try to access the page through a web browser I get a generic

example.com’s server DNS address could not be found.

Is/are there a reason(s) why I am getting what appears to be mixed results?

Note: I followed the instructions I found on stackoverflow about how to set this up.

Skam

Posted 2016-03-15T05:52:47.867

Reputation: 123

Write in your browser directly http://192.30.252.153/. Your DNS is not able to resolve the address in IP. When you incur in problem like that simplify your command line from all the not needed parts, and for your command becomes curl http://192.30.252.153/ where it is evident that you are not asking to reach example.com but that IP. :-) – Hastur – 2016-03-15T06:33:51.920

Answers

2

With the Curl call you are not using DNS, you are asking curl to go direct to the destination IP, but to tell the server which site you are after by sending a host: header.

With your browser, you are just putting the URL straight into the address bar, and so your DNS server must resolve example.com. It is unable to and so produces an error.

So the conclusion is that the DNS is not set up correctly.

Paul

Posted 2016-03-15T05:52:47.867

Reputation: 52 173