How to block all communication ports except the one(s) used by TeamViewer?

Hey guys and girls!

I wish to block all communications ports except the one(s) used by the TeamViewer application.

Before I submitted this post, I did some online search and found that I must edit the iptables configuration file… which I couldn’t do it by myself!

I have two requests:
a) I’m a newbie in Linux, so I will appreciate it if someone gives me a step-by-step procedure to do it correctly!
b) After the configuration is made, could anyone instruct me on how to check if all ports are all blocked except for the one allowed?

Thank you so much,


Hey Luis, there is of course a possibility of using firewall to block/unblock whatever you’d like. Is this what you’re looking for?

Well, if you would really block ANY communication expect TeamViewer you would have a hard time to get TeamViewer itself working - as you at least need access to DNS to get the teamviwer client connect to the teamviewer servers in the first place (or set up local DNS and hard-code it).
May I ask: WHY? What’s the purpose you require teamviewer so badly but want to lock down any other traffic like DNS and SSH? Can’t see any reason - except for parania caused by some severe miss-understanding.