The ion atmosphere around nucleic acids is an integral part of their solvated structure. However, detailed aspects of the ionic distribution are difficult to probe experimentally, and comparative studies for different structures of the same sequence are almost non-existent. Here, we have used large-scale molecular dynamics simulations to perform a comparative study of the ion distribution around (5′-CGCGCGCGCGCG-3′)2 dodecamers in solution in B-DNA, A-RNA, Z-DNA and Z-RNA forms. The CG sequence is very sensitive to ionic strength and it allows the comparison with the rare but important left-handed forms. The ions investigated include Na+, K+ and Mg2 +, with various concentrations of their chloride salts. Our results quantitatively describe the characteristics of the ionic distributions for different structures at varying ionic strengths, tracing these differences to nucleic acid structure and ion type. Several binding pockets with rather long ion residence times are described, both for the monovalent ions and for the hexahydrated Mg[(H2O)6]2+ ion. The conformations of these binding pockets include direct binding through desolvated ion bridges in the GpC steps in B-DNA and A-RNA; direct binding to backbone oxygens; binding of Mg[(H2O)6]2+ to distant phosphates, resulting in acute bending of A-RNA; tight ‘ion traps’ in Z-RNA between C-O2 and the C-O2′ atoms in GpC steps; and others.