The Nintendo WFC shut down in 2012, taking with it the ability for Generation 4 and 5 games to go online. But not all hope is lost: it is possible to go online again thanks to fan-run servers, which will let you use the GTS, download past Mystery Gifts, and re-enter the WiFi Club. To connect to these fan servers, you will need to change the DNS settings in your game, which is explained below. While this counts as hacking, it will not harm your game in any way, and is easily reversible.
Please don't advertise Pokemon you have gained this way as legitimate. While the game will recognise them as authentic event Pokemon, most players do not consider these Pokemon as legitimate. You are getting Pokemon and items through unofficial, unintended means.
The Generation 4 games can only connect to unsecured WiFi networks (WEP). This type of network is almost never used today due to security concerns, so there is a good chance you will need to set one up yourself. This guide does not cover how to create a WEP network.
The DS Lite can only connect to WEP networks, which are very difficult to find. However, the Gen V games also support more modern standards, so it is strongly recommended that you use a DSi or 3DS.
If you are using a DSi:
If you are using a 3DS:
To go back to using normal internet, simply turn the Auto-Obtain DNS option on again. This goes for both generations of games.
Each server can do slightly different things, so make sure you connect to one which suits your needs.
Secondary: 18.104.22.168 or 22.214.171.124
Pokemon uploaded to this server's GTS, along with uploaded battle videos, can be viewed here. This server provides a functioning GTS for all Gen IV and V games. It also allows Gen V players to use the WiFi Room and upload battle videos.
Primary: Either 172.104.088.237 or 104.131.093.087
This server has the most comprehensive collection of events distributed on Mystery Gift, from legendary Pokemon to items such as the Liberty Ticket or Oak's Letter. It also includes events for regions outside of the USA and Japan! However, if you haven't gotten what you wanted, try the server below.
This server has a somewhat limited selection of event Pokemon, although it has the added benefit of allowing Gen V players to use the WiFi Room.
Kyohack's GTS is no longer online, and as one of their forum staff says, their website only continues to be online for nostalgia purposes.
This method does not directly send events through Mystery Gift, but can be used to get legal event Pokemon anyway. What it does is send a copy of the event Pokemon you want to the GTS. You can choose which Pokemon to send from their events database. Only American or Japanese event Pokemon are available, but the Pokemon can be sent to all games regardless of region or language.
The Pokecheats website (go here for Gen V, and here for Gen IV) can also be used in conjunction with its GTS to create custom, legal Pokemon to send to this GTS (make sure you choose the "automatically fix PID" option). This is useful for creating competitive teams, or to get Pokemon you want.
A more detailed guide to the Pokecheats GTS can be found on their forums.