Recommended is, that you meet flies, mosquitos and ants -- as all outside influences -- with equanimity; they might even be a good meditation object to achive this state of mind...
Ajahn Brahm quoted Ajahn Chah once calling them 'Ajahn Mosquito' (see
below).
However! I personally rather prefer to find meditation spots, where I am bothered as little as possible, so the question does not even arise: if there is sun, sitting on a stone (which will get hot) removes most ants; finding a spot with a slight breeze and not too deep in underbrush sees most mosquitoes gone; and if flies are an issue, putting up an incense stick does the trick most of the time.
Which is why that I learn from my teacher in Thailand, you know, Ajahn Chah, you know “Ajahn” means “teacher”. And he said that anything which is irritating you, anything which is troubling you, THAT is your teacher. So being in north-east Thailand, we‟d always call the mosquitos “Ajahn Mosquito”. Coz I‟ve learned so much from those damn mosquitos! That‟s what I though at that time, those mosquitos, even when we used to do the loving kindness.
For those of you who are buddhist, you know that we spread loving kindness to all people, all beings, all genders, no matter what you are and who you are: may all beings be happy and well. However, as a young man, being a monk in Thailand, I just could not do that. It‟s impossible. So I did the best I can, I used to chant: “May all beings be happy and well, except mosquitos! May all beings be free from suffering, but not those mosquitos, they don‟t deserve after what they‟ve done to me!”
I‟m sure that when you ever do the “spread loving kindness”, you‟ll also have exceptions. But it didn‟t work well when I had exceptions, so I learned how to learn from those mosquitos, to be kind to them.
The teaching is a lake with shores of ethics, unclouded, praised by the fine to the good.
There the knowledgeable go to bathe, and cross to the far shore without getting wet.
[SN 7.21]