Unblocking blocked site with hosts file

10,564

Solution 1

Yes, this is incorrect. Host files are designed to map a single host or a list of hosts to a single IP address. Instead, you've attempted to map a host to a host.

Assuming www.another.com and www.somesite.com do point to the same IP address, you could try the following.

1 - Ping the address you can resolve, which is www.another.com.

ping www.another.com

2 - Assuming the IP is 1.2.3.4, copy it into the host file, enter a space, then enter the domain you wish to map.

1.2.3.4   www.somesite.com

3 - On Windows, you may need to flush your browser cache. Open a command prompt and type:

ipconfig /flushdns

4 - You may still need to restart your browser. On Mac and Unix-based systems, the changes should be immediate.

Note that, depending on how the site is blocked, you may need to use other methods to get through. If it's blocked by your ISP and not DNS, then you'll likely need to look for an Anonymous proxy in order to fetch the content from a proxy in another country. You can find some proxies here, as well as on Google. Good luck!

Note: You can add more than one host to a single IP by spacing out the addresses:

1.2.3.4  my.domain.com  www.somewhere-else.com  anotheraddress.net

Solution 2

Hostfiles point a domain name to an ip address (effectively acting like a A record), you can't use it to point a domain name to another name (like a C record). It simply dosen't work that way.

Share:
10,564
Umair A.
Author by

Umair A.

Updated on September 18, 2022

Comments

  • Umair A.
    Umair A. almost 2 years

    I have www.somesite.com blocked in my country. But I have another domain www.another.com that points to the same server and it's not blocked (Apache Virtual Host) and works fine.

    I put an entry in hosts file of my computer as follows.

    www.another.com          www.somesite.com
    

    I still can't access www.somesite.com. Am I getting hosts file all wrong?

  • Umair A.
    Umair A. over 11 years
    What if I say, this is single IP on which www.another.com, www.someother.com and few others are pointed by Apache Virtual Host. If I ping and get the IP address, this is not the webpage I want.
  • Umair A.
    Umair A. over 11 years
    This is the explicit need to map host to host. Is there a way in windows and mac to do that?
  • Umair A.
    Umair A. over 11 years
    Got it. Is there a way to explicitly map host to host in windows and mac?
  • Thalys
    Thalys over 11 years
    The way you expect it to work? not really. If you map foo.net to bar.org, the request the server recieves is for bar.org. Not much use there.
  • jmort253
    jmort253 over 11 years
    No, you cannot control host to host, not without the IP. Plus, the target server, if using NameVirtualHost, will interpret the request by hostname anyway, so all you can do is tell your computer to point the domain to a specific IP address. Like I said, if this doesn't work, you'll likely just need to use a proxy.