How to DNS spoof on Linux

DNS spoofing is when you force your operating system into thinking a domain is pointing to an IP address different from what the rest of the internet see's. This can be useful when you move a site from one server to another and want to test the site before pointing the domain to the new server.

Instructions

These instructions should work for the majority of Linux distributions available today. You must have super user access (root) to make the necessary changes. These instructions show how to make these changes via the command line.

  • Using your favorite text editor open “/etc/hosts”

At the bottom of the file you will need to add a new line. On this new line first enter the IP address followed by a space and then the domain as shown below.

10.0.0.1 domain.com

If your testing a website you will probably want to add the www prefix as well

10.0.0.1 domain.com www.domain.com

  • Now you can save and quit.

Do not forget to remove, or comment out the changes you made to this file when your done! If you forget your system will continue to force the domain to the IP address you specified.