1: What is the most effective way to play games online avoiding a ban: CIA installed games or Freeshop installed games?
Both forms are functionally identical. There is ongoing debate about the safety of Freeshop. The tool itself does nothing different from what a computer browser would do, but IP and MAC address matching potential, looking for patterns... it is not known how far, how often, and when Nintendo goes to look for stuff. There are people who have been using it consistently and have yet to get a ban. Those who were banned, it is difficult to say for sure what banned them.
2: Can I do some settings to the console to prevent risks of ban? Which settings?
We don't fully know what Nintendo looks for but we know they look for info sent by the console, so generally the less unnecessary stuff the better. Opt out of information-sending options like SpotPass, anonymous data sending about software, from System Settings, Mii Plaza, and everywhere you find it. It is also possible to set your Friends List not to broadcast what you're playing. This lowers the vulnerable surface. Keep in mind that the console STILL communicates this info to Nintendo it may just have fewer opportunities to do so. You want to avoid sending any info that involves running titles that are obviously illegal, such as homebrew or titles before their official release date. More on what can be done in the other questions...
3: Public headers? Private headers? What is that? (Explain me like I'm five)
Headers are a unique piece of data, like a serial number, that is sent when a game tries to connect online. For online connectivity, a valid header is needed. The header however, doesn't need to match the game. For CIA titles, the console's header is used and nothing needs to be done. For Gateway or Sky3DS users, a header is required. As far as experience has shown, Nintendo can ban public header users but not private ones, even if the same header is used on multiple titles. This leads us to believe that all they're looking for is if two identical headers are in use at the same time. Headers are also used as the encryption key for save files, so Gateway users must decrypt these or use other software in order to backup or edit save files.
4: What happens when a console is banned? Is it temporary or permanent? How do I know if it's temporary? Is the NNID banned or the console? Most effective way to unban?
In the past bans used to be temporary and last about 2 weeks. Since then, Nintendo appears to have grown confident in their detection schemes and a ban today related to suspected piracy is almost guaranteed to be permanent. Unbanning methods revolve around the idea of changing something called your firmware's LocalFriendCodeSeed_B, or LFCS, described
here. Note that method 3 still works and is not actually obsolete as the thread implies.
5: When my console is banned (temporary or permanently) am I also banned of playing Local Multiplayer? Is there any risk of getting my console banned if I play Local Multiplayer? (Freeshop game vs. Legit or viceversa or Freeshop vs. Freeshop)
Local multiplayer is completely unaffected by a console ban. Other local features such as StreetPass still work, and you are still able to use the Internet Browser. Anything having to do with Nintendo's servers however, is blocked.
6: (This is just out of curiosity) Could a 2nd hand console (being sold by the shop Cex for example) be banned of some sort? How can I check it?
Yes it is entirely possible. Not only that but it may be decieving too. Even if a console appears to be not banned initially, it is possible that its seed has been made public, or that at some point any one other person sharing the seed gets banned, in which case the original console gets banned too. It's also possible that the console has left a log of illicit software activity on Nintendo's servers, which has not yet been picked up but will be on Nintendo's next banwave sweep. Aside from trying to connect the console itself, you could check if it is hacked. If it is, the chance increases that the seed may have been dumped, or that the console was used online in a way that Nintendo caught on. It is not a sure thing however, as the previous owner could have removed the hack and all traces in order to sell the console without suspicion.
7: Is there anything I should also know about risks of ban and ways of avoiding it?
+Don't install CIA homebrew, use them through the Homebrew Launcher.
+Set all settings to broadcast running titles and anonymous info off.
+Do not go online with unreleased titles - not just to play them online but don't even turn your wireless on. Of all other suspect activities, Nintendo catches on and bans these the fastest it seems.
+Avoid installing paid DLCs that you did not buy.
+There MAY BE some risk in playing software titles only available on eShop that you didn't buy on your account. In general, try to keep your software titles consistent with your region. It's not clear if Nintendo really acts against this but the chances do increase if the game also has multiplayer functionality and you use out-of-region titles and definetly they won't work in local multiplayer with friends(yes Nintendo is stupid like that).
+Avoid software injects(like FBI into Health and Safety app) and if you do it, do it offline and then use a tool like Cthulhu to clear the icon/data cache. Check the Activity Log to make sure it appears as normal.+IF you're using an old flashcart(none on the market today, most from the pre-2012 era) that doesn't spoof a DS game, be aware that its usage will be pulled from the Activity Log and displayed as Last Run Title in Mii Plaza. The feature to do so and the option to disable sending this info to Nintendo exist. It is a rare case but worth mentioning if you want to make sure you're covering everything.
+Avoid using save editors for games with online features. Some edits might be harmless, others might be blatant hacks easily detectable and bannable by Nintendo. It's also possible that they may be subtle, like some internal data that can't happen on legit games or an inconsistency that is impossible.
+Do not use
cheats online. This should be fairly obvious.
+Always check if you're doing any sort of firmware changes(like deleting files to reset stuff or changing seeds etc.) that you do not put your console in a state where suspicion is aroused on Nintendo's servers. For example, your console having been EU and then suddenly it reports itself as US, or it was firmware 11.6 and now you changed it to 11.4. The more "weird stuff" is seen happening, the higher the chance you'll be suspected.