You can configure Google Chrome and Microsoft Edge to resolve a specific website to a custom IP address using the --host-resolver-rules flag. This is useful for testing or development, such as:
- Testing a new website deployment: Access the new version in Chrome and the live version in Firefox.
- Side-by-side comparison: Open different versions of the same website and easily copy and paste between them.
Note: This technique uses an advanced, unsupported feature. Our web design team uses this hack every day, and we encourage you to give it a try. However, it is not covered by Ecenica Support, and please use it at your own risk.
Steps for Google Chrome on Mac
- Quit Chrome
Close all running instances of Google Chrome. -
Open Terminal
Open Terminal by pressing Cmd + Space, typingTerminal, and pressing Enter. -
Run Chrome, or Edge with Custom Host Resolver Rules
Enter the following command:
open -a "Google Chrome" --args --host-resolver-rules="MAP example.com 100.100.100.100"Or for Edge:
open -a "Microsoft Edge" --args --host-resolver-rules="MAP ecenica.com 100.100.100.100"Be sure to replace
100.100.100.100with the IP address of your Ecenica server. -
Test the Configuration
Visitexample.comin Chrome. It will now resolve to the specified IP address. -
Restore Default Settings
Quit Chrome and reopen it normally to reset DNS resolution.
Steps for Windows
-
Quit Chrome
Close all running instances of Google Chrome. -
Locate Chrome’s Shortcut
- Right-click the Google Chrome shortcut on your desktop or Start menu.
- Select Properties.
- Edit the Target Field
In the Target field, append the following:–host-resolver-rules=’MAP example.com 100.100.100.100′
Example:
‘C:\Program Files\Google\Chrome\Application\chrome.exe’ –host-resolver-rules=’MAP example.com 100.100.100.100′
-
Save and Launch Chrome
Click OK to save. Use this shortcut to launch Chrome and resolveexample.comto the specified IP. -
Restore Default Settings
Close all Chrome windows and reopen Chrome normally.
Limitations and Notes
- Not Always Reliable: Support for
--host-resolver-rulesvaries across Chrome versions and operating systems. It may not always work as intended, particularly with IPv6. - Temporary Effect: This only affects Chrome during the current session.
- Advanced Users Only: Requires command-line or shortcut modifications.
For long-term changes, consider using your system’s hosts file or a local DNS server. Since this feature is experimental, it is not covered by Ecenica Support.
Browser Compatibility
Google Chrome
- Supports
--host-resolver-rules: Yes - Usage: Allows mapping specific domains to custom IP addresses on a per-session basis.
Firefox
- Supports
--host-resolver-rules: No - Alternative: Use extensions like SwitchHosts or configure a proxy server to map DNS.
Safari
- Supports
--host-resolver-rules: No - Alternative: Use system-wide changes (e.g., modify
/etc/hosts) or configure a custom proxy.
Microsoft Edge
- Supports
--host-resolver-rules: Yes - Usage: Same feature as Chrome due to Edge’s Chromium base.