I'm working with a 2011 MacBook Pro running Lion (10.7.2), that after waking from sleep (i.e. opening the lid) takes an inordinately long amount of time (2-3 minutes or more) to get a usable internet connection.
Upon waking, the wi-fi icon signifies it is negotiating a network connection, and completes one a few seconds later. At this point, network diagnostics will not show any issues, and everything in Network preferences looks as normal: I'm connected to the proper network, have the right IP address and gateway, and DNS settings are correct.
However, any site accessed with a domain name (like http://www.google.com) in Safari will return the "You are not connected to the Internet." error. Accessing a site directly, say, with Google's 74.125.226.212, is successful. Yet, Network Diagnostics will insist that DNS is functioning properly.
After a few minutes, the following lines will be printed to the Console log, and regular behavior will be restored.
11/18/11 8:11:31.288 PM airportd: _doAutoJoin: Already associated to “Wireless”. Bailing on auto-join.
11/18/11 8:11:32.000 PM kernel: en1: BSSID changed to 00:25:9c:63:91:bd
This behavior occurs only when waking from sleep--not when turning wi-fi on and off. This problem also occurs when using a wired Ethernet connection.
As per this thread, I have tried flushing the DNS cache and wiping the wireless network from memory (it's not a protected network). Neither have worked.