0

This is about Ubuntu but should be pretty much the same on all Linux flavors. Let's say I add an entry to my /etc/hosts such as

127.0.1.12   facebook.com

and an Apache virtual host such as

<VirtualHost 127.0.1.12>
   ServerName facebook.com
   DocumentRoot /var/www
</VirtualHost>

when i open my browser and send a GET request to facebook.com, firefox will browse my /var/www folder.

Question: How could I fetch (ie, using wget in bash) the real facebook.com domain - without erasing the entry in /etc/hosts nor my Apache VirtualHost -- IOW how could I bypass internal DNS?

3

Often the best setup is the other way around - Setup a DNS server with zones for the sites you want to spoof and point clients to your DNS server. Then you can set an outside set of servers in /etc/resolv.conf on your web server, or add a hosts entry pointing to the real site.

  • that's a really good idea! I wasn't thinking outside the box! I would vote you up but I don't have enough reputation :( thanks! – fabjoa Mar 12 '11 at 23:59
1

In /etc/nsswitch.conf, replace this:

hosts:          files dns

with this:

hosts:          dns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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