Thank you for your post. I recommend you the knowledge base article
Which ports are used by TeamViewer
I hope it is helpful for you to configure your settings in your firewall.
Thank you. But except for ports, I want to also limit access to global IP addresses, is this possible? do you have a list of addresses used?