For testing purposes, is it possible to circumvent DNS and send an HTTP request for a certain domain name to a specific IP address?

For example, let's say you are building a website for example.com on server 1.1.1.1.

Without updating the domain's actual DNS records (e.g. through the registrar or DNS provider) or fiddling with DNS locally (e.g. updating hosts file), how can you test how 1.1.1.1 would respond to an HTTP request for example.com?

this is a weird question.. HTTP request for a domain name.. well, HTTP requests are to an IP address, for webpages.. And if you're making an HTTP Request to a domain for a webpage(whatever that means!)-there is such a thing as a hosts header but it is for when one IP holds many domains,to get to that IP in the first place you'd need the IP or domain+translate to IP.The HTTP request is to an IP not to a domain. The situation would be a bit different perhaps, with a proxy server, but requests are still to IPs. So, it's hard to see what your question means or how it makes sense or what you mean.
–
barlopFeb 21 '14 at 15:35

3 Answers
3

First, you can issue the request by specifying the IP directly, i.e. http://192.168.99.99/web/path.

Second, each HTTP request includes a Host: header that tells the HTTP server what domain it wants to reach. This exists so that multiple domains can live on a single IP. So if you can find a browser extension or other tool that lets you issue a request and specify that manualy, you can do it.

I'm not familiar with that Chrome extension but using IP addresses instead of the the DNS records that resolve to them is not a reliable means of testing website behavior. For example, the HTTP/1.1 spec introduced the idea of a Host: header, this permitted virtual hosting (multiple sites sharing an IP address, and I would argue a consequent explosion in inexpensive website hosting). My point is that if you use an IP address rather than a FQDN your browser (with exception to Chrome extension and similar) will not be generating the same headers as it would with a published DNS record, so it's not a real test in the real world.

The "typical" way to do this is exactly what you're trying to avoid: hosts files, "split" DNS, etc.

There is a Google Chrome extension called DNS Overrider that will allow you to enable a DNS override of a URL on a page. For example, if I had a local html file on my computer that IFRAME'd a url (http://example.com) then I could use this extension to create an alias that points to 1.1.1.1.

However, keep in mind that this will not work in your address bar. It will only work on the URLs within a page. Using the IFRAME element should work.