关于如何阻止网络端口被使用的任何想法,或者 目前正在使用吗?例如,假设我想阻止端口 23 正在使用。使用,我的意思是允许与它的连接。
提前致谢。
最佳答案
该解决方案需要通过命令行完成,但是您可以使用 python 的操作系统库来运行脚本。这个link也是一个类似的问题(只是端口不同),因此您可以调整该命令,然后通过以下脚本运行它
import os
# specify the command prompt command you need to be run
command = 'netsh advfirewall firewall add rule name="BlockAIM" protocol=TCP dir=out remoteport=23 action=block'
# assign variable to the command
output = os.popen2(command)
# To get output call output.read()
以下脚本会阻止传出请求,因此您需要使用 dir=in 重复该过程
关于python - 遇到端口应用程序阻塞问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42754802/