How to close TCP and UDP ports via windows command line

后端 未结 17 1600
忘掉有多难
忘掉有多难 2020-12-07 06:43

Does somebody knows how to close a TCP or UDP socket for a single connection via windows command line?

Googling about this, I saw some people asking the same thing.

相关标签:
17条回答
  • 2020-12-07 07:21

    instant/feasible/partial answer : https://stackoverflow.com/a/20130959/2584794

    unlike from the previous answer where netstat -a -o -n was used incredibly long list was to be looked into without the name of application using those ports

    0 讨论(0)
  • 2020-12-07 07:23

    I found the right answer to this one. Try TCPView from Sysinternals, now owned by Microsoft. You can find it at http://technet.microsoft.com/en-us/sysinternals/bb897437

    0 讨论(0)
  • 2020-12-07 07:27

    In order to close the port you could identify the process that is listening on this port and kill this process.

    0 讨论(0)
  • 2020-12-07 07:28

    Try the tools TCPView (GUI) and Tcpvcon (command line) by Sysinternals/Microsoft.
    https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview

    0 讨论(0)
  • 2020-12-07 07:29

    If you know the port that you want to free you can sort your netstat list by looking for the specif port like this:

    netstat -ano | findstr :8080
    

    Then the pid will appear at the rigth which you can kill with taskkill.

    taskkill/pid 11704 /F
    

    Also you may want to look at this question which is specifically for localhost, but I think it is relevant:

    0 讨论(0)
  • 2020-12-07 07:33

    Use TCPView: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
    or CurrPorts: https://www.nirsoft.net/utils/cports.html

    Alternatively, if you don't want to use EXTERNAL SOFTWARE (these tools don't require an installation by the way), you can simply FIRST run the netstat command (preferably netstat -b ) & then setup Local Security Policy to block the IP address of the user's machine in question, that's what I have been doing with unwanted or even unknown connections - that allows you doing everything WITHOUT ANY EXTERNAL SOFTWARE (everything comes with Windows)...

    0 讨论(0)
提交回复
热议问题