Cure is antibiotic drops:
I like Floxin otic suspension but there are others. If ear canal is swelling shut you will need an ear wick(like a sponge placed in the ear). You may need oral antibiotics should things worsen or if the middle ear is involved. I find that Augmentin works well for this.
The goal is to prevent otitis externa maligna. If your external ear is getting red, hot, swollen you need to be seen immediately.
Prevention: various over the counter preparations. They all have alcohol to dry the ear.
You can make your own very easily:
1/2 rubbing alcohol
1/2 3% white vinegar (this helps maintain proper ear pH and avoid skin from becoming excessively dry).
Put a few drops in after swimming, etc. First dry the ear by placing finger with a towel up to your ear canal and tip head, wiggle, etc. Then use drops.
Qtips and ear plugs etc cause problems with this as well. I see more problems with people who swim in lakes and rivers than in pools FWIW. I swim in a lake-very clean as lakes go.
Hope this helps.