server unable to find route to api.twitter.com

5 minutes ago, my server was unable to find route to api.twitter.com. mtr showed a blank screen. /etc/init.d/networking restart fixed the problem but I would like to understand what went wrong so that I can troubleshoot it more precisely next time. Any ideas ?

UPDATE : here is what the host command shows:

host api.twitter.com
api.twitter.com has address 199.16.156.199
api.twitter.com has address 199.16.156.40
api.twitter.com has address 199.16.156.104

after flushing the cache, one route changes:

host api.twitter.com
api.twitter.com has address 199.16.156.40
api.twitter.com has address 199.16.156.104
api.twitter.com has address 199.16.156.231

Solution 1:

As you can see api.twitter.com has a multiple A records

# host api.twitter.com 216.187.125.130
Using domain server:
Name: 216.187.125.130
Address: 216.187.125.130#53
Aliases:

api.twitter.com has address 199.59.150.9
api.twitter.com has address 199.59.149.199
api.twitter.com has address 199.59.149.232

# host api.twitter.com 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

api.twitter.com has address 199.16.156.199
api.twitter.com has address 199.16.156.72
api.twitter.com has address 199.16.156.231

So it is possible that one node of the "cluster" has failed and all packets tried to reach failed node. As you can see each route has TTL

# ip ro get 199.59.150.9
199.59.150.9 via 209.15.xxx.xxx dev em1  src 209.15.xxx.xxx
    cache  mtu 1500 advmss 1460 hoplimit 64

# ip -s route show cache 199.16.156.231
199.59.150.9 via 209.15.xxx.xxx dev em1  src 192.168.207.10
    cache  users 1 used 38 age 17sec ipid 0x7f34 mtu 1500 advmss 1460 hoplimit 64
199.59.150.9 from 209.15.xxx.xxx via 209.15.xxx.xxx dev em1
    cache  users 1 age 20sec mtu 1500 advmss 1460 hoplimit 64

I think you can use the following command to clean your cache

# ip route flush cache 199.59.150.9

You can get more info at http://vincent.bernat.im/en/blog/2011-ipv4-route-cache-linux.html