You said you know you are ugly. Now most people will say that what others think wont matter and everyone is beautiful in their own way. That is somewhat true, but there is a general understanding what beautiful and ugly is, so there is that as well.
I'm ugly as well, the best thing you can do, what I do, is to wear that like armor(yes I'm quoting game of thrones because it's true.).
Wear it like your armor so it cannot be used to hurt you. When someone tells you that you are ugly, just either ignore it completely or tell them "I know" and move on.
The reason why they tell you this is most likely to hide their flaws or boost their egos by hurting you. If you show no reaction to this comments first of all, you will see how meaningless their opinion is and feel better yourself, and second they will stop making these comments because it wont give them any satisfaction any longer.
Remember, they are not gods, they are not legends, they are not more or less important than you. They are just humans like you. They are entitled to their opinions. But it doesn't, and shouldn't effect your life.
I hope this helps somewhat. Be strong. Live life the way you want to live it.
I want to tell what I really think. But there are too many voices giving me very different opinions.