One way to keep a drain free of odors is to run very hot tap water through the drain after each use. Also, try to avoid getting vegetable matter or grease in a kitchen drain or letting hair accumulate in a bathroom drain (hair entraps other odorous matter). Treat any partially clogged drain promptly.
To rid a drain of odors, about once a week pour in a handful of baking soda, then run very hot tap water through it. Or, pour in 1 cup of vinegar, let it stand for 30 minutes, then rinse with a stream of hot water.