Open the terminal (Ctrl+Alt+T) and run this command (root privileges is required):
sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 –dport 3389 -j ACCEPT
Replace 3389 with the port you want to open.
How do you close the ports?
Simply replace ACCEPT with DROP as follows:
sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 –dport 3389 -j DROP