First off, this is possible on the Nintendo 3DS, 3DS XL, 2DS, and 2DS XL for both generation 4 and 5, as well as the Nintendo DS and DS Lite for Generation 4. Nintendo DSi does not work for this, unfortunately
Ok, I’ll start with the easy one.
Gen 5 (BWB2W2)
To begin, have internet connection on your DS.
Go to “Change Settings” and get to “DNS”. Select the option to not auto obtain DNS. Make the primary DNS 164.132.44.106. Leave the secondary DNS as all zeroes. Now, go to the Mystery Gift on your game and you can get mystery gifts. It will select a random one, and you can’t get the same twice. The following are
what you can get:
Scrafty (Lvl 50, 2011 Worlds)
Karrablast (Lvl 50, European Summer 2011 Pokemon Day)
Secret Egg (TRU 2011, Random 3 from Anime: Ash's Pidove, Iris's Axew, and Cilan's Pansage)
Pikachu (Lvl 50, 2012 Worlds, knows "Fly" move)
Pikachu (Lvl 100, 2012 Pika Pika Carnival event in Singapore, OT: Fes)
Pikachu (Lvl 100, Germany Summer 2012 Pokemon Day)
Victini (Lvl 50, Pokemon the Movie 2012 Black and White, has V-Create move)
Mewtwo (Lvl 70, Feb 2012, 1st Anniversary)
Darkrai (Lvl 50, May 2012, Dark Explorer's tie-in)
Keldeo (Lvl 15, Summer 2012, Black 2/ White 2 Pre Release)
Shiny Larvitar (Lvl 5, 2012 Worlds)
Shiny Dialga (Lvl 100, Summer 2013, Gamestop)
Shiny Palkia (Lvl 100, Summer 2013, Gamestop)
Shiny Giratina (Lvl 100, Summer 2013, Gamestop)
Smeargle (Lvl 50, 2013 Worlds)
Mewtwo (Lvl 100, 2013 Extremespeed Genesect Pre-Order Event in Japan)
Ray's Shiny Metagross (Lvl 45, 2013 Regionals)
Woler's Ludicolo (Lvl 30, 2013 Spring Regionals)
Cloyster (Lvl 30, 2013 Winter Regionals, Abram's)
Meloetta (Lvl 50, Spring 2013 Gamestop/ EB Games/ GAME)
Zekrom (Lvl 100, Spring 2012, Has "Bolt Strike" move)
Reshiram (Lvl 100, Spring 2012)
Zoroark (Lvl 50, Summer 2011, TRU)
Deoxys (Lvl 100, 2013, B2W2 Only)
Genesect (Lvl 15, Fall 2012, B2W2 Launch event, "Techno Blast" move)
Liberty Pass (Item to meet Victini)
Shelmet (Lvl 50, EU Pokemon Day 2011)
Now for the hard one.
Gen 4
> “ For the Gen 4 games, however, their internet settings were individual in each game. So, head into the opening menu, just after the title screen of your choice of game. Somewhere on the list, it’s going to mention Nintendo WFC. For Pokemon HeartGold and SoulSilver, use the above paragraph to do the same thing, but within the game settings. For Diamond, Pearl, and Platinum, it takes some additional steps.
Starting off, do you have Mystery Gift unlocked yet? Head to Jubilife City and into the Jubilife TV building. On the third floor, find the man in the bottom left area and he will ask two questions. For the first question, choose “Everyone” “Happy”, then for question two, answer “Wi-fi” “Connection”. This will unlock Mystery Gift in the usual menu before you start the game.
For the three in question, however, the stars have to align and you’ll need an older-style WPS setting on your router. Some older Wireless-N routers have them built in and it’s a matter of a setting. But, it will ask for the WPS code that is used instead of the usual password. Some phone hotspots have this ability built in as well and may take some additional settings to fiddle with. (In my case, it was not to be, no matter how hard I tried.) Try the same DNS settings as above (164.132.44.106), but another additional possibility is putting 178.62.43.212 as the primary and setting the secondary to 1.1.1.1 or 8.8.8.8. If none of these options work, you may be out of luck for this one.
Update December 3 2018: Gen 4 will work, but has to be configured within the game itself (use the same info, but once you're inside the game). You have to be using an older router or lower end hotspot under WEP to get it to work though. It will not connect without it. If it gets code 52100, you may need to put it on an iPhone network or you're out of luck. For help with solving the 60000 error, see below. As for the 52100 error, there's loads of great information available on the Mystery Gift post featured over on the Pokemon subreddit.”
As for the Pokémon:
HGSS:
Shiny Suicune (Lvl 30, Winter 2011)
Shiny Entei (Lvl 30, Winter 2011)
Celebi (Lvl 50, Winter 2011)
Crobat (Lvl 30, Worlds 2010)
Ash's Pikachu (Lvl 50, TRU)
Mew (Lvl 5, Fall 2010)
Jirachi (Lvl 5, Summer 2010)
Shiny Eevee (Lvl 50, Video Game Championship 2010)
Enigma Stone (Lvl 40, Latios in HG or Latias in SS)
Amity Meadows (Pokewalker Route Info, Japanese)
Rally (Pokewalker Route Info, Japanese)
Sightseeing (Pokewalker Route Info, Japanese)
Yellow Forest (Pokewalker, All Pikachu)
Winner's Path (Pokewalker Route Info)
Lock Capsule (Unofficial, separate Wonder Card section)
DPPT:
Jirachi (Lvl 5, Summer 2010)
Celebi (Lvl 50, Winter 2011)
Shiny Milotic (Lvl 50, Video Game Championships 2009)
Shiny Suicune (Lvl 30, Gamestop Event)
Shiny Entei (Lvl 30, Gamestop Event)
Shiny Raiku (Lvl 30, Gamestop Event)
Shiny Pichu (Lvl 30, Spring 2010, When brought to HGSS can give you Spiky Eared Pichu)
Crobat (Lvl 30, Worlds 2010)
Ash's Pikachu (Lvl 50, Phantom Champion Zoroark 2010)
Scizor (Lvl 50, Phantom Champion Zoroark 2010)
Regigigas (Lvl 100, TRU USA)
Regigigas (Lvl 100, EU Movie)
Deoxys (Lvl 50, 2008 Gamestop)
Arceus (Lvl 100, 2009 TRU)
Manaphy (Lvl 50, AU JB Hi-Fi)
Manaphy (Lvl 50, TRU)
Manaphy (Lvl 50, Nintendo World)
Crobat (Lvl 30, 2010 Worlds)
Weavile (Lvl 30, 2009 Worlds)
Lucario (Lvl 30, 2008 Worlds)
Darkrai (Lvl 50, ALAMOS, 4 possible with diff ID)
Shaymin (Lvl 50, TRU, Gracidea)
Dragonite (Lvl 50, TRU)
Pikachu (Lvl 20, Nintendo Zone, Knows "Present")
Key Item: Secret Key
Key Item: Membership Card
Key Item: Oak's Letter
Key Item: Unofficial, Azure Flute
App: Feeling Checker
App: Alarm Clock
Hope this helps!
Source: Experience and this