What prevents sewer gas are plumbing traps.
In plumbing, a trap is a device which has a defined shape by utilizing curves or/and angles along a pipe path, to abduct gray or waste water, and prevent backflow or gases, vermin or insects from entering a building, while allowing any gray or waste water to continue flow downstream.
Plumbing Traps, P-Trap
Just below a Sink or Wash Basin is the Tail Piece. An Inlet drain pipe mounted just above the Trap Adaptor connected to the Plumbing Trap.
The Plumbing Trap below the Trap Adapter in this image is referred to as a P-Trap, which in of itself, is a Plumbing Fixture and device.
P-trap consists of the Inlet, Trap Adapter, Top & Lower Dip, P-Trap, Cleanout, Trap Weir Seal or Crown Weir Seal below the Trap Crown, Outlet and Trap Arm.
A Plumbing Trap, by definition, is a device that retains a measured amount of water. When, in this case, lavatory fixtures are utilized, an amount of water is retained in the P-Trap while the rest of the water is drained. The water that remains in the P-Trap device is referred to as, The Trap Seal.
P Trap serves several functions.
1: Backflow prevention.
2: Trap Debris.
The Trap Seal serves several functions.
1: Prevent Sewage Odors & Gases, a complex mixture of toxic and nontoxic gases produced and collected in sewage systems, from escaping/dispersing into the room.
2: Impeding Vermin, Mice and Insects from exiting the drain pipe into your home.
The above image or a P-Trap was provided by InterNACHI, International Association of Certified Home Inspectors. The world’s largest inspection trade association founded by Nick Gromicko.