genjutsu effects the chakra in the mind, thus effecting the five senses, I guess there's really now way to "avoid" it, but ninjas who have a high intelligence or specialize in genjutsu themselves has a better chance of knowing when they are in one. it can be broken by stopping the flow of chakra, then apppling something like a chakra burst throughout the body. or a partner can send their chakra through the body of the one caught in it. because of this, a perfect jinchuriki, will almost never get caught in a genjutsu