efflandt
Posts: 359
Joined: Mon Dec 03, 2012 2:47 am
Location: Elgin, IL USA

wget failing to resolve (solved)

Sun Dec 16, 2012 3:45 pm

In Raspbian I had been having trouble using wget to resolve anything, including goo.gl to get rpi-update, and once I figured that out, getting rpi-update to work (which uses wget). Not sure of the exact cause, but it seems that something does not like DNS name resolution that includes ipv6 addresses (wget, my LAN router, the internet?).

Example:

Code: Select all

[email protected] ~ $ host www.google.com
www.google.com has address 74.125.225.211
www.google.com has address 74.125.225.212
www.google.com has address 74.125.225.208
www.google.com has address 74.125.225.209
www.google.com has address 74.125.225.210
www.google.com has IPv6 address 2607:f8b0:400f:801::1014

[email protected] ~ $ wget www.google.com -O /dev/null
--2012-12-16 09:07:45--  http://www.google.com/
Resolving www.google.com (www.google.com)... failed: Name or service not known.
wget: unable to resolve host address `www.google.com'
If I force ipv4, then it works:

Code: Select all

[email protected] ~ $ wget -4 www.google.com -O /dev/null
--2012-12-16 09:08:22--  http://www.google.com/
Resolving www.google.com (www.google.com)... 74.125.225.211, 74.125.225.212, 74.125.225.208, ...
Connecting to www.google.com (www.google.com)|74.125.225.211|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `/dev/null'

    [  <=>                                               ] 13,847      36.2K/s   in 0.4s

2012-12-16 09:08:22 (36.2 KB/s) - `/dev/null' saved [13847]
To avoid having to edit scripts that use wget, tell it to globally force ipv4 by editing /etc/wgetrc and adding a line:

Code: Select all

inet4_only = on
Then wget will work without inserting an option to force ipv4 (and sudo rpi-update will work):

Code: Select all

[email protected] ~ $ wget www.google.com -O /dev/null
--2012-12-16 09:24:28--  http://www.google.com/
Resolving www.google.com (www.google.com)... 74.125.225.210, 74.125.225.211, 74.125.225.212, ...
Connecting to www.google.com (www.google.com)|74.125.225.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `/dev/null'

    [   <=>                                              ] 13,907      12.9K/s   in 1.1s

2012-12-16 09:24:29 (12.9 KB/s) - `/dev/null' saved [13907]

pangren
Posts: 42
Joined: Thu Dec 19, 2013 2:52 pm

Re: wget failing to resolve (solved)

Wed Jan 01, 2014 5:59 am

Awesome answer thanks for helping out on this! I've been struggling with this problem for awhile

Return to “Troubleshooting”