I gotta agree - to some degree - with the theory that the iPhone after 3.1 seems to have some sort of firmware issue relating to WiFi.
I recently upgraded all of my equipment. It's state of the art stuff, recent firmware, etc... I have DSL with a WiFi access-point/router, and a repeater in a separate building. The whole network is running in G, and using WPA2 security. Normally, my 3GS connects to the main router and/or the repeater just fine. The WPA2 presents no problems whatsoever.
But occasionally the iPhone does have trouble similar to the kind mentioned above. In settings, there is a check-mark next to the WiFi network, but the WiFi symbol either doesn't come on at the top of the screen, or it disappears quickly and reverts back to the 3G symbol. Further investigation (clicking on the > arrow on the right side of the WiFi network tab) indicates that while the iPhone is connected to the router - it has no IP address from the DHCP server. This happens while other computers easily negotiate IP addresses with the DHCP server. I'm able to resolve it eventually with power cycles or resetting network settings. Once the iPhone successfully negotiates the IP address from DHCP, it'll work just fine on the LAN for days or even weeks on end, even after I've logged onto other WiFi networks in other areas.
On some occasions, I think failures to connect have been the result of IP conflicts on the network - either with another machine, or with the repeater. These were resolved with full resets of all the equipment and devices.
I do think that somehow, this hints at a possible cause of problems with the iPhone. It seems to me that it handles its IP address differently than do other devices. Windows XP or 7 on my computers seems to handle IP addresses in a truly dynamic fashion, so that when the machine powers down or sleeps, it acquires a new address from DHCP each time it powers back up (if a new address is necessary). By contrast, the iPhone seems to want to hold onto the same IP address indefinitely through sleep-wake cycles (because of the nature of its power state in contrast to a computer, I suppose). Sometimes, I think that while the iPhone is in sleep state (in which state it disconnects from WiFi and reverts to 3G), the router's DHCP server hands out an IP address to a computer that the iPhone is still holding on to, and then when the iPhone wakes up, there's a conflict and it doesn't know what to do to resolve it. This seems to be why renewing the lease or turning WiFi off, or resetting network settings seems to help.
All that to say, there is SOME problem that my iPhone has connecting to DHCP that none of my other devices have. They all connect quickly and without issue every time, whereas occasionally, the iPhone has trouble.
I think it's got to be a firmware (not a hardware) issue, where the iPhone OS has trouble completing the DHCP handshake under some conditions. It seems to me - as I said above - that this MAY have to do with the way the iPhone tries to retain its IP address in sleep state, where the Router may reassign that address to the next device that connects to the network, resulting in a conflict that the iPhone has trouble resolving.
From my experience - the best you can do is to follow the advice given above. Make SURE your router's firmware is up to date. Try renewing the lease on the iPhone's WiFi connection. If that fails, then reset the network settings and power-cycle the phone (full reset). You may need to power cycle your router also - in order to reset the DHCP server, to eliminate any IP conflicts.
Some people have noticed that setting a static IP address on the iPhone helps, which also seems to indicate that the core issue may have to do with the DHCP handshake. You might try assigning a static IP that is at the upper end of the DHCP server's range (so that it won't try to hand that address dynamically to another device).
Hope that helps some... let me know what you find, or any thoughts you all have.
Message was edited by: SteveCWatkins