usually, they have some sort of weapon to use when they are in danger, such as bees: they can protect themselves by stinging. Ladybugs defend themselves by producing a poisin like substance(usually orange ladybugs). Ants can also defend themselves by biting what they think it delisious.
Thorns, alkali poisons, being indigestible. There are some plants that have coevolved with species of ants. They provide the ants sustenance and a place to nest and the ants provide protection to the plant.