Faulty routes on MacOS X


This has been driving me insane, but I haven’t had time to actually try to fix the problem until now, so this is a small writeup about the symptom and what you can do about it. Sadly, it’s kinda a hard problem to search for, unless you already knows whats wrong.

This was my problem: At work, accessing LiveJournal worked fine, but at home it didn’t. Basically I got a Server Not Found from Firefox when trying to access from home. After a while I realized that the distinction wasn’t between home/work, but wireless or wirebound network. See, at work I usually use a wire to connect, but I only use wireless at home.

My first shot at a solution was something that solved a similar problem a while back – namely flushing the DNS cache. Of course, doing an nslookup and verifying it told me that the cache wasn’t the problem, but I tried anyway, because MacOSX sometimes plays funny tricks with this cache. So, to do this, just do “sudo lookupd -flushcache” in a console window, and then restart the network interface.

I tried to figure out what was wrong by pinging, and doing traceroute. Both of these gave clues that something was wrong. Traceroute gave me “Can’t assign requested address” from the bind system call. That finally made me realize that the route tables for the network interface was screwed. Lo and behold, doing a “sudo route flush” and restarting the interface solved my problems. Apparently there were about 10 faulty routes stuck in the cache, and for some reason MacOS X didn’t flush this cache automatically when connecting to a different wireless network. Highly annoying, but it’s finally solved.