As I understand it, IBS is a type of allergy. Your gut is having an adverse reaction to something you're eating. You fix the problem by figuring out what that thing is, and not eating it.
In my case it was nuts. Not peanuts, but almost any kind of nuts that grow on trees (almonds, walnuts, pecans, hazelnuts). I'm not sure about coconut - that's a whole different botanical class (phylum? order?). So far, I haven't had any problems with seeds (sunflower seeds, pumpkin seeds, grains).