Home >Common Problem >What is the cmd command to open a port?
What is the cmd command to open a port?
View port
To view the port in Windows 2000/XP/Server 2003, you can use the Netstat command:
Click " Start → Run", type "cmd" and press Enter to open the command prompt window. Type "netstat -a -n" in the command prompt and press the Enter key to see the port number and status of the TCP and UDP connections displayed in numerical form.
Netstat command usage
Command format: Netstat -a -e -n -o -s-an
-a means to display all activities TCP connections and the TCP and UDP ports that the computer listens on.
-e means displaying the number of bytes sent and received by Ethernet, the number of data packets, etc.
-n indicates that only the addresses and port numbers of all active TCP connections are displayed in numerical form.
-o means display active TCP connections and include the process ID (PID) of each connection.
-s means displaying statistical information of various connections by protocol, including port numbers.
-an View all open ports
Close the port
For example, to close port 25 of the SMTP service in Windows 2000/XP, you can do this : First open the "Control Panel", double-click "Administrative Tools", and then double-click "Services". Then find and double-click the "Simple Mail Transfer Protocol (SMTP)" service in the service window that opens, click the "Stop" button to stop the service, then select "Disabled" in the "Startup Type", and finally click "OK" ” button. In this way, closing the SMTP service is equivalent to closing the corresponding port.
Open the port
If you want to open the port, just select "Automatic" in the "Startup type", click the "OK" button, and then open the service. Click the "Start" button in "Service Status" to enable the port. Finally, click the "OK" button.
Tip: There is no "Service" option in Windows 98. You can use the firewall's rule setting function to close/open the port.
The above is the detailed content of What is the cmd command to open a port?. For more information, please follow other related articles on the PHP Chinese website!