For security reasons, you should limit the usage of an inbound local port to just the single receiving program. Plus in many cases you should configure that program not to use its standard port number (if possible). Instead, pick a number between 1024 and 49151 (inclusive and random) to be your inbound local port number.
First identify what Windows 7 calls your router's 'Network Location'. (Later we'll need this.) Here's how to do it:
- In Control Panel, click 'Network and Sharing Center'.
- Under the words 'View your active networks', identify (of your active routers) which is the appropriate one. (Most people only have one active router.)
- Find and click the text you see, immediately under that active router. Then
- Observe which Network Location is selected (i.e., surrounded by a dotted box).
- You should decide (if you haven't already) whether this router is best considered as providing:
- A Home Network (a private network);
- A Work Network (in a corporate domain); or
- A Public Network.
Then set up Windows Firewall to allow your desired inbound connection to the receiving program. (You'll need to be an Administrator for this.) Here's how:
- In Control Panel, click 'Windows Firewall'.
- Click 'Advanced Settings'—this takes you to 'Windows Firewall with Advanced Security'.
- Click 'Inbound Rules'.
- Click 'New Rule'.
- Select 'Port' and click 'Next'.
- Ensure 'TCP' is selected.
- Ensure 'Specific local ports' is selected.
- Enter your local inbound port number and click 'Next'.
- Ensure 'Allow the Connection' is selected, and click 'Next'.
- For 'When does this rule apply?', ensure that the box by your router's Network Location (see above) is checked (but no other Network Locations are), and click 'Next'.
- Under the word 'Name', enter the name of the receiving program, then a word (or an abbreviation) indicating (to you) the port's purpose (or functionality), the words 'In' and 'Port', and the port number (all five concatenated together). Click 'Finish'. (Later, this naming scheme will ease finding this rule, if necessary.)
- Click 'Refresh'.
- Right-click your new rule and select 'Properties'.
- Click the 'Advanced' tab.
- If you need this local inbound port to be accessible merely from other computers within your LAN, then:
- Under 'Edge traversal', ensure 'Block edge traversal' is selected. This prevents computers outside your LAN from initiating contact with this inbound port on your computer (at least, through this Windows Firewall 'Action: Allow' rule).
- Under 'Edge traversal', unselect 'Block edge traversal'.
- Click the 'Programs and Services' tab.
- Select 'This program'.
- Enter the path to your receiving program and click 'OK'.