robinyanwang
asked on
how to open/close ports using DOS command
I know netstat to check current ports using in my workstation, but I do not know which command to control these ports?
Can anyone help? thanks/
-S
Can anyone help? thanks/
-S
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open ports are associated with services running on your PC. You need to find out what service uses that port, then shut off that service using the Services administrative tool, or by shutting down the third party application that opens the port.
Netstat -an will show you your "listening" ports... the ones opened by services and apps.
C:\>netstat -an
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:21 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING
rich
Netstat -an will show you your "listening" ports... the ones opened by services and apps.
C:\>netstat -an
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:21 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING
rich
Might start looking here
http://www.microsoft.com/technet/scriptcenter/scripts/os/process/default.mspx
http://www.microsoft.com/technet/scriptcenter/scripts/os/process/default.mspx
robinyanwang, your question was "how to open/close ports using DOS command........I do not know which command to control these ports?"
I don't understand how the answer you accepted, using netstat, answers your question of how to open or close ports. Netstat, as you yourself stated, simply displays protocol statistics. Future readers look to the accepted answer as a solution. Selecting an incorrect answer is misleading for them. You may wish to; re-open the question, change the awarded points, or if no answer is acceptable, ask to have the question closed. You can do so by posting a question in the community support page.
Thanks,
--Rob
I don't understand how the answer you accepted, using netstat, answers your question of how to open or close ports. Netstat, as you yourself stated, simply displays protocol statistics. Future readers look to the accepted answer as a solution. Selecting an incorrect answer is misleading for them. You may wish to; re-open the question, change the awarded points, or if no answer is acceptable, ask to have the question closed. You can do so by posting a question in the community support page.
Thanks,
--Rob
Well, here's a problem that I'm having:
When I use
netsh firewall delete portopening tcp XXX
or even
netsh firewall add portopening tcp blab lbabl ablab
and then I use the netstat utility to view the open ports, I still see the one (that I closed) listed.
Example:
>netsh firewall add portopening tcp 91 randomport
>netstat -a|find /n /i "91"
>
But when I open the windows firewall GUI, I see the port that I added. (it's just not reflected by netstat). Arg.
I also agree (respectifully) with RobWill re:the accepted solution.
When I use
netsh firewall delete portopening tcp XXX
or even
netsh firewall add portopening tcp blab lbabl ablab
and then I use the netstat utility to view the open ports, I still see the one (that I closed) listed.
Example:
>netsh firewall add portopening tcp 91 randomport
>netstat -a|find /n /i "91"
>
But when I open the windows firewall GUI, I see the port that I added. (it's just not reflected by netstat). Arg.
I also agree (respectifully) with RobWill re:the accepted solution.
netsh firewall add portopening TCP 80 HTTP enable subnet
Where service is HTTP, Port is 80, Protocol is TCP and allowed scope is the subnet
Some useful articles
A general overview:
http://www.windowsnetworking.com/articles_tutorials/Using-Netsh-Windows-Firewall.html
Condensed instruction/syntax:
http://www.jsifaq.com/SUBP/tip7900/rh7908.htm
Very detailed instructions starting on page 37 of the following Microsoft document:
http://download.microsoft.com/download/6/8/a/68a81446-cd73-4a61-8665-8a67781ac4e8/wf_xpsp2.doc