The peritrophic matrix (PM) forms a layer composed of chitin and glycoproteins that lines the insect intestinal lumen. This physical barrier plays a role analogous to that of mucous secretions of the vertebrate digestive tract and is thought to protect the midgut epithelium from abrasive food particles and microbes. Almost nothing is known about PM functions in Drosophila, and its function as an immune barrier has never been addressed by a genetic approach. Here we show that the Drosocrystallin (Dcy) protein, a putative component of the eye lens of Drosophila, contributes to adult PM formation. A loss-of-function mutation in the dcy gene results in a reduction of PM width and an increase of its permeability. Upon bacterial ingestion a higher level of expression of antibacterial peptides was observed in dcy mutants, pointing to an influence of this matrix on bacteria sensing by the Imd immune pathway. Moreover, dcy-deficient flies show an increased susceptibility to oral infections with the entomopathogenic bacteria Pseudomonas entomophila and Serratia marcescens. Dcy mutant flies also succumb faster than wild type upon ingestion of a P. entomophila toxic extract. We show that this lethality is due in part to an increased deleterious action of Monalysin, a pore-forming toxin produced by P. entomophila. Collectively, our analysis of the dcy immune phenotype indicates that the PM plays an important role in Drosophila host defense against enteric pathogens, preventing the damaging action of pore-forming toxins on intestinal cells.