Commands to use CMD to close ports: 1. Use CMD to close specific ports; 2. Use CMD to close all open ports; 3. Use CMD to open specific ports; 4. Use CMD to open all open ports.
In the Windows operating system, you can use Command Prompt or PowerShell to close the port. The following is an example of a command to use CMD to close a port:
1. Use CMD to close a specific port:
netsh advfirewall firewall add rule name="Close Port" dir=in action=block protocol=TCP localport=<端口号>
Replace cb0e4711f79077fa4e7e0b4e52a8fd16 with the port number to be closed. For example, to close port 80, you can run the following command:
netsh advfirewall firewall add rule name="Close Port" dir=in action=block protocol=TCP localport=80
2. Use CMD to close all open ports:
netsh advfirewall firewall add rule name="Close All Ports" dir=in action=block protocol=any localport=any
This command will close all open ports. Note that this may block all network communication, including applications and services.
3. Use CMD to open a specific port:
netsh advfirewall firewall add rule name="Open Port" dir=in action=allow protocol=TCP localport=<端口号>
Similarly, replace cb0e4711f79077fa4e7e0b4e52a8fd16 with the port number to be opened. For example, to open port 80, you can run the following command:
netsh advfirewall firewall add rule name="Open Port" dir=in action=allow protocol=TCP localport=80
4. Use CMD to open all open ports:
netsh advfirewall firewall add rule name="Open All Ports" dir=in action=allow protocol=any localport=any
This command will open all open ports. Note that this may allow all network traffic, including potentially insecure connections.
Remember, before running these commands, make sure you have the appropriate permissions and understand what is being done. Closing or opening ports may have an impact on network security, so proceed with caution.
The above is the detailed content of CMD close port command. For more information, please follow other related articles on the PHP Chinese website!