We focus on the confinement of two-dimensional Dirac fermions within the waveguides created by realistic magnetic fields. Understanding of their band structure is of our main concern. We provide easily applicable criteria that can guarantee existence or absence of the energy bands and, this way, provide a valuable insight into the systems where analytical solution is impossible. The general results are employed in specific systems where the waveguide is created by the magnetic field of a set of electric wires or by a magnetized strip.