Eating more fiber, which is found in whole grains, vegetables and fruits, might help protect against dangerous bacteria in the gut.