Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I think this may not be possible because of the way the TCP/IP protocol defines packets, but I figured I'd ask.

Some sites, such as those on shared servers, use the same IP and the server delivers the site based on the hostname/URL requested. In this situation, doing a DNS lookup of the site IP and going to the IP directly will usually deliver some other content that is not the site with the given hostname.

Is there a way to have it both ways and request a site using the IP address but have the request still show the hostname/url so that the server on the other still handles the request as though you provided the URL and it was resolved via DNS?

The specific use case for me is a private DNS server being down so my browser can only access via the raw IP (which I have backed up) but the site needing the URL to deliver the correct content. However I think just knowing this is possible is interesting on its own and the technique worth knowing in general.

share|improve this question
1  
Why not run your own DNS server or edit the hosts file on the computer itself, you can hard code that hostname in to it and it won't make the request out to the slow DNS server. –  Scott Chamberlain Sep 22 '13 at 18:27
    
Because its a VPN and it seems like it has to pass through the vpn dns server first. My only basis for thinking this is setting an ssh proxy to a host on the remote lan which uses a different DNS server from the VPN gateway and the URL still resolving via VPN gateway DNS server. –  Anthony Sep 22 '13 at 18:39
    
You could set up a local DNS server on your computer and have it go to the VPN's DNS server for any entries it does not have cached locally. –  Scott Chamberlain Sep 22 '13 at 18:43
    
Wouldn't the SOCKS proxy work the same way? –  Anthony Sep 22 '13 at 18:44

1 Answer 1

up vote 1 down vote accepted

If you modify /etc/hosts file and add the IP address and site into it, you should be able to pick up the site by URL with a standard browser as this file is normally read before DNS, and will solve the problem for you.

I don't know if any browsers (assuming you don't call curl a browser) support it, but it is technically possible to request a site using the IP address rather then URL. The problem is rendering it.

In order to allow multiple HTTP sites on a single IP address, web browsers use the HTTP 1.1 specification. This specification means that after connecting to the IP address on port 80 the browser then advises the web server the name of the server it wanted the content from. Thus, using a decent telnet client you can get a dump of the site you want. (If you dump the output to a file you can probably render it in a browser !)

A sample session might be this. Say you want to go to get the home page of the site "www.lightbox.net.nz/" which resides on a server configured by default to produce another page if accessed via IP address 60.234.77.229

telnet 60.234.77.229 80         (Typed)                                   
Connected to 60.234.77.229.     (Server Response)
Escape character is '^]'.       (Server response)
GET /index.php HTTP/1.1         (Typed - to request the root web page using http/1.1 protocol)
host: www.lightbox.net.nz     (Tell the server which site you want)
                                (blank line to tell it you have finished asking)
Output of http://www.lightbox.net.nz/index.php shown here.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.