Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intercept DNS request in a Chrome Extension?

If I want to test http://www.domain.com, but I want to test two versions of it by switching the IP out (e.g. one resolves to 127.0.0.1 and the other 192.168.1.200) is it possible to write/use a chrome extension to handle intercepting the DNS query and resolving to my IP of choice?

The current workaround is to utilize the hosts file and flush the DNS cache to switch between them but that's less than optimal and was hoping a browser extension could handle the same thing.

like image 393
Shane Avatar asked May 18 '11 13:05

Shane


1 Answers

There's no mechanism to manipulate DNS requests/responses natively inside Chrome, not even via the upcoming WebRequest API.

Is there a reason that you need to test with exactly the same domain name? Setting up a dev environment on something like http://dev.example.com/ (or http://example.dev/ if you run your own DNS or have edited your hosts file) is a clean mechanism for producing the effect you want in a way that's functional with the APIs you have access to; writing an extension that gave you a button to toggle between the two domains with the push of a button would be trivial

like image 143
Mike West Avatar answered Oct 05 '22 03:10

Mike West