All metazoan guts are in permanent contact with the microbial realm. However, understanding of the exact mechanisms by which the strength of gut immune responses is regulated to achieve gut-microbe mutualism is far from complete. Here we identify a signaling network composed of complex positive and negative mechanisms that controlled the expression and activity of dual oxidase (DUOX), which 'fine tuned' the production of microbicidal reactive oxygen species depending on whether the gut encountered infectious or commensal microbes. Genetic analyses demonstrated that negative and positive regulation of DUOX was required for normal host survival in response to colonization with commensal and infectious microbes, respectively. Thus, the coordinated regulation of DUOX enables the host to achieve gut-microbe homeostasis by efficiently combating infection while tolerating commensal microbes.