For opening ports in Windows, you just need to follow these simple instructions:
Go to the Control Panel and click System and Security.
In the resulting window, click Windows Firewall.
In the Windows Firewall window, click Advanced Settings on the left pane.
Note: You must be logged in as an Administrator to make changes to the Firewall Settings.
You should see a window titled Windows Firewall with Advanced Security.
In this window, click Inbound Rules.
On the right pane, you will see an option for a New Rule. Click it.
Choose Port and click next
Choose the Type of Port you want, choose Specific port and write the port you want to open
Choose Allow Connection and click next.
Choose when do want to apply this rule and press next.
Last Step Name the Rule and Press Finish.
For opening ports in Ubuntu, you have two options; scripting or using wizard.
First: opening ports using wizard:
Open Gufw Firewall Configuration.
Click on the plus button under the rules
Give the rule a name.
Choose allow in policy combo box
Then choose both in Direction box.
Then choose do not log in “Log” box.
Write wanted port at “1” position, IP at “2” position the press add.
Second: Opening Port Using Scripting:
Before opening or closing ports, we recommend to first verify if the port is open or closed and who is using the port. There a number of different commands:
Commands to verify ports:
to verify single port
netstat -nap | grep <port #>
to list all current rules in iptables
For opening a TCP port:
iptables -A INPUT -p tcp –dport <port #> -j ACCEPT
For opening a UDP port:
iptables -A INPUT -p udp –sport <port #> -j ACCEPT
iptables-save > /etc/iptables.rules
If you need to disable the firewall temporarily, you can flush all the rules using: