29

I have a local DNS server that resolves all URLs *.domain.tld to 127.0.0.1. Also, I have the production server with the same address *.domain.tld. They have the same names, because subdomains interact with each other, and I have hardcoded domain URLs. I can't change them in the production server.

The problem is to reach the production server from my developer computer without touching the DNS server and /etc/hosts.

I found some options for Chrome such as --dns-server, --host-rules, but none is working. I have Google Chrome 23.0.1271.64 and Chromium 22.0.1229.94 on Ubuntu 12.10 64-bit.

acelot
  • 391

5 Answers5

4

In case the --host-rules does not work, try --host-resolver-rules.

Example: --host-resovler-rules=MAP example.com 127.0.0.1.

Note that we do not need to double quote the "MAP ... ..." part. (Verified in Version 89 of both Chrome non-headless and Chrome headless mode).

Also see a discussion on this: https://bugs.chromium.org/p/chromium/issues/detail?id=798793

3

You could use an extension to redirect a named HTTP request to one using an IP address.

This solution doesn't require any modification of the DNS or hosts file, and this redirection may possibly be enabled on and off via the extension :

Switcheroo Redirector

harrymc
  • 498,455
3

Chromium's DNS resolver is broken, and it won't respect the order in resolv.conf. So when I try to connect to hosts on my VPN, which the system resolves correctly using the VPN's DNS server, Chromium instead uses the non-VPN DNS, and resolves it to my internet provider's advertisement page (which they gratuitously reply with to any non-resolving host).

The only solution I've found was to add private IPs to /etc/hosts.

Ketil
  • 39
1

FoxyProxy Chrome extension worked nicely for me. It is also available for Mozilla Firefox as well. However, can take some time to configure initially. Have tested only for locally hosted sites without HTTPS.

Host Switch Plus extension for Chrome worked for me. Though easier to configure, as it allows multiple tagged entries for different environments as well. However, it seems to have some error which causes it to fail sometimes.

-1

https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh

DNS Overrider

This extension allows you to override domain names inside web-pages. DNS Overrider allows you to replace a current hostname with an alias. Hostnames will be changed in tags like <img>, <script>, <a>, <link>. Only hostnames with a specified alias will be replaced.

Using DNS Overrider you can replace hostname on the fly without access to system settings such as hosts file. DNS Overrider enables you to select what rules to apply via the extension settings page.

DNS Overrider is a useful Chrome extension for website and blog developers (both front-end and back-end developers). If you work with a test version of your site, you can easily and instantly override hostnames for images, scripts, anchors, style sheets without making any changes in the code and evaluate website markup and design correctness.

DNS Overrider extension is intuitive and easy to use. Install the extension, enter an orignal hostname in the "hostname" field, then input a desired alias in the "alias" field and click the "add" button. The rule will be applied to all pages which contain any elements of the provided hostname.

Spooky
  • 438
ANT
  • 7