The gut microbiota is an important contributor to host health and fitness. Given its importance, microbiota composition should not be left to chance. However, what determines this composition is far from clear, with results supporting contributions of both environmental factors and host genetics. To gauge the relative contributions of host genetics and environment, specifically the microbial diversity, we characterized the gut microbiotas of Caenorhabditis species spanning 200-300 million years of evolution, and raised on different composted soil environments. Comparisons were based on 16S rDNA deep sequencing data, as well as on functional evaluation of gut isolates. Worm microbiotas were distinct from those in their respective soil environment, and included bacteria previously identified as part of the C. elegans core microbiota. Microbiotas differed between experiments initiated with different soil communities, but within each experiment, worm microbiotas clustered according to host identity, demonstrating a dominant contribution of environmental diversity, but also a significant contribution of host genetics. The dominance of environmental contributions hindered identification of host-associated microbial taxa from 16S data. Characterization of gut isolates from C. elegans and C. briggsae, focusing on the core family Enterobacteriaceae, were also unable to expose phylogenetic distinctions between microbiotas of the two species. However, functional evaluation of the isolates revealed host-specific contributions, wherein gut commensals protected their own host from infection, but not a non-host. Identification of commensal host-specificity at the functional level, otherwise overlooked in standard sequence-based analyses, suggests that the contribution of host genetics to shaping of gut microbiotas may be greater than previously realized.