The gut microbiota contributes to host health and fitness, and imbalances in its composition are associated with pathology. However, what shapes microbiota composition is not clear, in particular the role of genetic factors. Previous work in Caenorhabditis elegans defined a characteristic worm gut microbiota significantly influenced by host genetics. The current work explores the role of central regulators of host immunity and stress resistance, employing qPCR and CFU counts to measure abundance of core microbiota taxa in mutants raised on synthetic communities of previously-isolated worm gut commensals. This revealed a bloom, specifically of Enterobacter species, in immune-compromised TGFβ/BMP mutants. Imaging of fluorescently labeled Enterobacter showed that TGFβ/BMP-exerted control operated primarily in the anterior gut and depended on multi-tissue contributions. Enterobacter commensals are common in the worm gut, contributing to infection resistance. However, disruption of TGFβ/BMP signaling turned a normally beneficial Enterobacter commensal to pathogenic. These results demonstrate specificity in gene-microbe interactions underlying gut microbial homeostasis and highlight the pathogenic potential of their disruption.