I have trouble with name resolution when using programs like
gem in my shell within my office environment.
Whenever a program needs to connect to a remote host, it fails to resolve the domain name, but after a "manual resolution" e.g. via
ping the same command will succeed.
Basically, this is what I have to do now:
$ gem install guard-sass ERROR: Could not find a valid gem 'guard-sass' (>= 0), here is why: Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/latest_specs.4.8.gz) ERROR: Possible alternatives: guard-sass $ ping rubygems.org PING rubygems.org (22.214.171.124): 56 data bytes Request timeout for icmp_seq 0 ^C --- rubygems.org ping statistics --- 3 packets transmitted, 0 packets received, 100.0% packet loss $ gem install guard-sass Fetching: guard-sass-1.3.2.gem (100%) Successfully installed guard-sass-1.3.2 Parsing documentation for guard-sass-1.3.2 Installing ri documentation for guard-sass-1.3.2 1 gem installed $
This problem is not specific to one command or programming language, but rather occurs on any of the following:
gem- Uses ruby under the hood
composer- Uses php
vagrant- Uses ruby
brew- Uses ruby
git- Uses C
- Mac OS X 10.9 (Had the same issue on 10.8 as well)
It does not affect any browsers or other applications with a GUI.
The problem doesn't occur in other environments (e.g. at home) with the same machine.
Any idea on how to troubleshoot this kind of problem?
- I get both IP address and DNS server address via DHCP both at the office and at home.
- I also tried using an external DNS server like Google's
- The Mac only goes to sleep while transferring between office and home (no full reboot).
- I tried both using the same shell and opening a new session when experiencing this issue at the office. Also tried a full restart of the computer and flushing DNS cache (
dscacheutil -flushcache;sudo killall -HUP mDNSResponder).