# Internet problems after emerge update

## tempuser

Since updating my system many of my applications cannot use the Internet.  Examples include w3m, getmail and youtube-dl.  Interestingly ping and seamonkey still work.  Below I have listed some sample error messages.

w3m:

```
Can't load http://www.amazon.co.uk/
```

getmail:

```
socket error ([Errno 2] No such file or directory)
```

youtube-dl:

```
WARNING: unable to set language: <urlopen error [Errno 2] No such file or directory>

ERROR: unable to download video webpage: <urlopen error [Errno 11] Resource temporarily unavailable>
```

Instinctively I suspect some networking library has broken on my system.  Despite this revdep-rebuild has shown up no problems.

Sudo makes no difference thus permissions are not the issue here.  Troubleshooting this issue has proved beyond me.  I humbly request help from anyone willing to give it.

----------

## Hu

Are the affected applications unable to use the Internet or unable to use DNS?

----------

## tempuser

DNS apparently.  I am basing this on the fact w3m can access web pages if I use their IP address.

----------

## slackline

What is the contents of /etc/resolv.conf ?

This file holds details for DNS, if its not pointing to a valid DNS server then you won't be able to resolve domain names.

If you've a local network the contents of this may simply be that of your router, if thats the case then check that the router is configured with valid DNS serves.  These are usually provided by your ISP, but you can always add secondary (and sometimes tertiary) DNS serves so Google's 4.4.4.4 and 8.8.8.8 are good, simple options.

----------

## tempuser

Resolv.conf:

```

# Generated by dhcpcd from wlan0

# /etc/resolv.conf.head can replace this line

domain <censored>

nameserver <censored>

# /etc/resolv.conf.tail can replace this line

```

I use my router's IP address as the name server.  I know this works, because it has done so for a long time.  Furthermore substituting in 4.4.4.4 did not fix the problem.

----------

## tempuser

Anyone?

----------

## Hu

What is the output of dig hostname @<censored>; dig hostname @4.4.4.4?

----------

## slackline

Well whilst your computer is pointing to your router correctly, have you...

 *slack---line wrote:*   

> check that the router is configured with valid DNS servers.  These are usually provided by your ISP, but you can always add secondary (and sometimes tertiary) DNS serves so Google's 4.4.4.4 and 8.8.8.8 are good, simple options.

 

You say you substituted in 4.4.4.4, but as written its ambiguous and it sounds as though you did this on your computer rather than your router perhaps (although of course you may have meant you tried it on your router, but thats not clear from how you've written it).

----------

## tempuser

 *Hu wrote:*   

> What is the output of dig hostname @<censored>; dig hostname @4.4.4.4?

 

dig hostname @<censored>:

```

; <<>> DiG 9.9.2 <<>> hostname @<censored>

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54598

;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4000

;; QUESTION SECTION:

;hostname.         IN   A

;; AUTHORITY SECTION:

.         10716   IN   SOA   a.root-servers.net. nstld.verisign-grs.com. 2012122900 1800 900 604800 86400

;; Query time: 16 msec

;; SERVER: <censored>#53(<censored>)

;; WHEN: Sat Dec 29 12:37:31 2012

;; MSG SIZE  rcvd: 112

```

dig hostname @4.4.4.4:

```

; <<>> DiG 9.9.2 <<>> hostname @4.4.4.4

;; global options: +cmd

;; connection timed out; no servers could be reached

```

 *slack---line wrote:*   

> Well whilst your computer is pointing to your router
> 
> correctly, have you...
> 
>  *slack---line wrote:*   check that the router is configured with valid DNS
> ...

 

I misread your previous message and substituted 4.4.4.4 in my resolv.conf, not

my router.  Regardless all the other computer on the network access the

Internet, through the same router, without a problem.  Thus the problem does

no lie with the router.

----------

## Hu

 *tempuser wrote:*   

>  *Hu wrote:*   What is the output of dig hostname @<censored>; dig hostname @4.4.4.4? 
> 
> dig hostname @<censored>:
> 
> ```
> ...

 Although you mishandled the commands I gave you, the output is still useful.  This seems to show that you simply cannot talk to 4.4.4.4 at all, so failure while using it does not excuse your router.  Currently, 4.4.4.4 is not answering me either.  Perhaps it no longer serves requests from arbitrary Internet users.  Server 8.8.8.8 does answer me.  Does it answer you?

----------

## tempuser

 *Hu wrote:*   

> Although you mishandled the commands I gave you, the output is still useful.  This seems to show that you simply cannot talk to 4.4.4.4 at all, so failure while using it does not excuse your router.  Currently, 4.4.4.4 is not answering me either.  Perhaps it no longer serves requests from arbitrary Internet users.  Server 8.8.8.8 does answer me.  Does it answer you?

 

Yes.

dig hostname @8.8.8.8:

```

; <<>> DiG 9.9.2 <<>> hostname @8.8.8.8

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 8048

;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 512

;; QUESTION SECTION:

;hostname.         IN   A

;; AUTHORITY SECTION:

.         1800   IN   SOA   a.root-servers.net. nstld.verisign-grs.com. 2012122901 1800 900 604800 86400

;; Query time: 48 msec

;; SERVER: 8.8.8.8#53(8.8.8.8)

;; WHEN: Sat Dec 29 21:02:49 2012

;; MSG SIZE  rcvd: 112

```

----------

## tempuser

A breakthrough, running w3m with the '-4' option fixes the problem for that application.  For w3m it appears the problem consisted of using ipv6 on a network that does not support it.  This still raises the question why the problem appeared, across the system, after an emerge update.  Are there any system configs that might have caused this.

----------

## Hu

Some versions of glibc, when asked to resolve a name as IPv4 or IPv6, issue DNS queries in a way that can confuse certain braindamaged DNS servers into giving bad responses.  I thought that such versions were not in circulation, but looking back, I see you never said what you updated or gave us any details about your system.  What is the output of emerge --info?  What exactly did you update between when the system was normal and when you first encountered problems?

----------

## tempuser

Another breakthrough, the problem with w3m stems from the 'getaddrinfo()'

system function misbehaving.  The following program demonstrates this.

Test program:

```

#include <string.h>

#include <errno.h>

#include <stdio.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netdb.h>

#include <netinet/in.h>

#include <arpa/inet.h>

void testgetaddrinfo( const char * title , const char * service , int ai_family );

int main( int n , char * * cpp )

{

    testgetaddrinfo("[\"http\", AF_INET]", "http", AF_INET);

    testgetaddrinfo("[\"http\", AF_INET6]", "http", AF_INET6);

    testgetaddrinfo("[\"http\", AF_UNSPEC]", "http", AF_UNSPEC);

    testgetaddrinfo("[\"80\", AF_INET]", "80", AF_INET);

    testgetaddrinfo("[\"80\", AF_INET6]", "80", AF_INET6);

    testgetaddrinfo("[\"80\", AF_UNSPEC]", "80", AF_UNSPEC);

    testgetaddrinfo("[0, AF_INET]", 0, AF_INET);

    testgetaddrinfo("[0, AF_INET6]", 0, AF_INET6);

    testgetaddrinfo("[0, AF_UNSPEC]", 0, AF_UNSPEC);

}

void testgetaddrinfo( const char * title , const char * service , int ai_family )

{

    struct addrinfo hints;

    struct addrinfo * pai;

    int gai_rval;

    memset(&hints, 0, sizeof(hints));

    hints.ai_family = ai_family;

    hints.ai_socktype = SOCK_STREAM;

    gai_rval = getaddrinfo("www.youtube.com", service, &hints, &pai);

    if (!gai_rval)

    {

        freeaddrinfo(pai);

   printf("%s: Success\n", title);

    }

    else

    {

       printf("%s: getaddrinfo() return value %d (%s). ", title, gai_rval, gai_strerror(gai_rval));

   if (gai_rval == EAI_SYSTEM)

       printf("errno = %d.", errno);

   printf("\n");

    }

}

```

Output:

```

["http", AF_INET]: Success

["http", AF_INET6]: getaddrinfo() return value -11 (System error). errno = 0.

["http", AF_UNSPEC]: getaddrinfo() return value -11 (System error). errno = 0.

["80", AF_INET]: Success

["80", AF_INET6]: getaddrinfo() return value -11 (System error). errno = 0.

["80", AF_UNSPEC]: getaddrinfo() return value -11 (System error). errno = 0.

[0, AF_INET]: Success

[0, AF_INET6]: Success

[0, AF_UNSPEC]: Success

```

In other words if one calls 'getaddrinfo()' with a non-null service and the

address family hinted as 'AF_INET6' or 'AF_UNSPEC' then the function returns a

value indicating a system error without setting errno.  The 'getaddrinfo()'

man page does not describe this behaviour as valid.

I would appreciate any suggestions.

----------

## Hu

Are you sure errno is unset?  Your test program calls printf before reading the value of errno, so printf could be clearing a valid error code.

----------

## tempuser

I do not believe that that would explain the behaviour.  In any case I have

altered the program to:

```

#include <string.h>

#include <errno.h>

#include <stdio.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netdb.h>

#include <netinet/in.h>

#include <arpa/inet.h>

void testgetaddrinfo( const char * title , const char * service , int ai_family );

int main( int n , char * * cpp )

{

    testgetaddrinfo("[\"http\", AF_INET]", "http", AF_INET);

    testgetaddrinfo("[\"http\", AF_INET6]", "http", AF_INET6);

    testgetaddrinfo("[\"http\", AF_UNSPEC]", "http", AF_UNSPEC);

    testgetaddrinfo("[\"80\", AF_INET]", "80", AF_INET);

    testgetaddrinfo("[\"80\", AF_INET6]", "80", AF_INET6);

    testgetaddrinfo("[\"80\", AF_UNSPEC]", "80", AF_UNSPEC);

    testgetaddrinfo("[0, AF_INET]", 0, AF_INET);

    testgetaddrinfo("[0, AF_INET6]", 0, AF_INET6);

    testgetaddrinfo("[0, AF_UNSPEC]", 0, AF_UNSPEC);

}

void testgetaddrinfo( const char * title , const char * service , int ai_family )

{

    struct addrinfo hints;

    struct addrinfo * pai;

    int gai_rval;

    int errnocopy;

    memset(&hints, 0, sizeof(hints));

    hints.ai_family = ai_family;

    hints.ai_socktype = SOCK_STREAM;

    gai_rval = getaddrinfo("www.youtube.com", service, &hints, &pai);

    errnocopy = errno;

    if (!gai_rval)

    {

        freeaddrinfo(pai);

        printf("%s: Success\n", title);

    }

    else

    {

        printf("%s: getaddrinfo() return value %d (%s). ", title, gai_rval, gai_strerror(gai_rval));

        if (gai_rval == EAI_SYSTEM)

            printf("errno = %d.", errnocopy);

        printf("\n");

    }

}

```

The output has not changed.

----------

## tempuser

Anyone?

----------

## Genone

Sounds like this patch could be the troublemaker: http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cfde9b463d63092ff0908d4c2748ace648e2ead8#patch5

----------

## tipp98

I am possibly having the same issue after @world update. If it is related to glibc then there is more to the story because I have the same version, glibc-2.15-r3, on two computers, one is fine. It could also have something to do with baselayout 2.2, as that is on the broken computer and not the other. Another difference is that the broken one had -ipv6 in make.conf, the other did not. 

# cat /etc/conf.d/network

```
ifconfig_eth0="192.168.1.44 netmask 255.255.255.0"

defaultroute="gw 192.168.1.1"
```

# route -n

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo                              <---added by me, from the working computer

127.0.0.0       -               255.0.0.0       !     0      -        0 -                               <---not on working computer

192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
```

# cat /etc/resolv.conf

```
nameserver 192.168.1.1
```

# ifconfig

```
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.44  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::216:76ff:fec9:2b65  prefixlen 64  scopeid 0x20<link>

        ether 00:16:76:c9:2b:65  txqueuelen 1000  (Ethernet)

        RX packets 1143  bytes 103961 (101.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 1077  bytes 240247 (234.6 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device interrupt 20  memory 0xe4500000-e4520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 67  bytes 7244 (7.0 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 67  bytes 7244 (7.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

----------

## tipp98

Ok, my problem became apparent after booting from a backup drive, when things still did not work. Seems after the post update reboot my router got confused and stopped sending dns to the computer. After router reboot I am ok.

----------

