A buildup of bacteria, hair, soap scum, or other material in the pipes is likely to be the cause of a smelly bathroom drain. If your bathroom drain has an unpleasant odour, try these solutions:

To begin, throw a pot of boiling water down the drain. Any detritus that might be the source of the stench would be flushed away.
One cup of baking soda and one cup of vinegar mixed together and poured down the drain should do the trick. Organic matter that might be contributing to the odour can be decomposed by the reaction between the two substances. After 15 to 20 minutes, flush the drain with hot water to remove the combination.
Combine a quarter cup of salt with a quarter cup of baking soda, and then flush it down the toilet. Don't flush with hot water for at least fifteen to twenty minutes after you've let it sit.
Squeeze the juice of half a lemon down the drain and let it sit for 15-20 minutes before flushing with hot water. Since lemons are naturally acidic, they can aid in decomposing whatever organic matter is behind the odour.
If none of the aforementioned approaches seem to be doing the trick, you can always try a commercial drain cleaning. However, before using a drain cleaner, make sure you read the instructions and observe all safety measures, as these products often contain toxic chemicals.
It's best to prevent bathroom drain odours before they start than of trying to fix them after the fact. You can keep hair and other debris from clogging your drain by installing a drain guard. Keep the drain clean by flushing it with hot water and a drop or two of dish soap on a regular basis. Finally, avoid putting anything that can solidify, such grease, oil, or other chemicals, down the drain.