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 dig
or 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 (54.245.255.174): 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 hoodcomposer
- Uses phpvagrant
- Uses rubybrew
- Uses rubygit
- Uses C
System:
- Mac OS X 10.9 (Had the same issue on 10.8 as well)
- zsh
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?
Follow up:
- 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
8.8.8.8
. - 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
).