A class of linear elliptic operators has an important qualitative property, the so-called maximum principle. In this paper we investigate how this property can be preserved on the discrete level when an interior penalty discontinuous Galerkin method is applied for the discretization of a 1D elliptic operator. We give mesh conditions for the symmetric and for the incomplete method that establish some connection between the mesh size and the penalty parameter. We then investigate the sharpness of these conditions. The theoretical results are illustrated with numerical examples.