Animals harbor diverse microbial communities that play important roles in their health and fitness. The gut microbiome is complex, with its composition shaped by a complex interplay of diet, host genetics, microbial interactions, environmental factors, and stochasticity. Previous work in the lab has highlighted the central role of genetic factors, identifying the DBL-1/BMP immune signaling pathway in shaping gut microbiome composition. My dissertation work started with the goal of identifying the downstream mediators of the DBL-1/BMP pathway that regulated gut commensal abundance, but went on subsequently to study additional forces that shaped commensal abundance, in particular environmental stress, exploring the participation of host genetic factors in reshaping the microbiome in response to toxin exposure.Chapter 1 of this dissertation reviews the use of Caenorhabditis elegans as a model organism to study the role of host genetics in shaping gut microbiome composition. With a characteristic gut microbiome that is distinct in its composition from its environment and as a genetically tractable system, C. elegans provides a valuable platform for dissecting the interactions between host genes and microbial communities. This chapter focuses on the influence of TGFβ/BMP signaling, particularly the DBL-1/BMP immune pathway, in regulating microbiome composition. This pathway plays a key role in controlling Enterobacter abundance, preventing overproliferation which can change this normally beneficial commensal into a harmful pathogen. Notably, this regulation occurs in the anterior intestine but is mediated by DBL-1 signaling in extra-intestinal tissues. Thus, chapter 1 highlights C. elegans as a robust model for identifying genetic factors that shape the gut microbiome and further introduces cross-tissue regulation of host-microbiome interactions.Chapter 2 examines how DBL-1/BMP signaling pathway shapes the gut microbiome composition in C. elegans. Through RNA sequencing, I identified gene targets regulated by DBL-1/BMP signaling, which were expressed in the intestine, and predicted to be secreted. Among the verified targets were genes encoding C-type lectins and lysozymes, which are associated with immune responses, but also nuc-1 and scl-2 which are not thought to affect the gut microbiome and whose function remains to be elucidated. Disruption of these genes led to increased colonization by bacteria of the Enterobacteriaceae family. Furthermore, intestine-specific disruption of these genes and epistasis analysis demonstrated that these genes were regulated by DBL-1 signaling in the intestine. The results describe a network of intestinal effectors mediating the effects of DBL-1/BMP signaling on gut microbiome composition, expanding our understanding of host-microbiome interactions.Chapter 3 examines the role of gut bacteria in host adaptation to changing environments, particularly to environmental toxins. I found that gut microbiome provides protection from the antibiotic neomycin, which is toxic to worms and variably toxic to its gut bacteria. Neomycin exposure led to delayed worm development and reduced survival. However, colonization with neomycin-resistant bacterial strains conferred protection. Among four protective strains, Stenotrophomonas indicatrix consistently dominated the gut microbiome under toxin exposure, providing protection via its aminoglycoside-3′-phosphotransferase (APH(3’)) enzyme. Using 16S rRNA gene sequencing, bacterial quantification, and behavioral assays, I identified two distinct protective mechanisms: (1) microbiome remodeling through altered microbial competition that enriched S. indicatrix in the gut, and (2) host-driven avoidance behavior favoring colonization by APH(3’)-expressing bacteria. This behavioral response was driven by the stress-activated KGB-1/JNK MAPK signaling pathway. These findings suggest that microbiome remodeling is a simple yet effective strategy for hosts to cope with novel environmental stressors. However, this adaptation comes with trade-offs, including increased vulnerability to infections and metabolic shifts. My results suggest the dynamic interplay between host behavior and microbial communities in adapting to environmental challenges, while also emphasizing the potential trade-offs associated with such adaptations.