[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to open/close ports using DOS command

Posted on 2006-05-03
6
Medium Priority
?
50,519 Views
Last Modified: 2009-04-28
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
0
Comment
Question by:robinyanwang
6 Comments
 
LVL 12

Accepted Solution

by:
Bob Lamberson earned 450 total points
ID: 16601730
robinyanwang,
type netstat /? at the prompt

Bob
0
 
LVL 78

Expert Comment

by:Rob Williams
ID: 16601760
There are a series of commands. For example to open a port:
   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
0
 
LVL 3

Expert Comment

by:rich255
ID: 16601765
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:jabiii
ID: 16605132
0
 
LVL 78

Expert Comment

by:Rob Williams
ID: 16721561
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
0
 
LVL 5

Expert Comment

by:forrestoff
ID: 20406966
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question