[英]How to Disable access to localhost (internal network and internet)
I want to block a program from accessing the local server "local host" (On windows) temporary so i can test random disconnections cases... I tried adding a (rule) to the firewall for disabling both inbound and outbound in all.networks types but the program just got block from accessing the inte.net not the local.network我想暂时阻止程序访问本地服务器“本地主机”(在 Windows 上),这样我就可以测试随机断开连接的情况...我尝试向防火墙添加一个(规则)以禁用 all.networks 中的入站和出站类型,但程序刚刚被阻止访问 inte.net 而不是 local.network
Moving on to an answer instead of a comment - nevertheless, more information on your use-case is greatly appreciated;继续回答而不是评论 - 尽管如此,非常感谢有关您的用例的更多信息;
I think it is impossible to block access to localhost but allow inte.net access.我认为不可能阻止对 localhost 的访问但允许 inte.net 访问。 Two reasons:
两个原因:
UPDATE after OPs comment OP评论后更新
I assume you are on Windows 10, and you know the path to the executable of the program you want to block.我假设您使用的是 Windows 10,并且您知道要阻止的程序的可执行文件的路径。
Kinda hard to provide detailed answer having only the information you've provided, but I think this scenario can be easily tested with simple containers configuration: having both program under test and "localhost" service running in containers, you can randomly update container's.network configuration to simulate connectivity issues.很难提供仅包含您提供的信息的详细答案,但我认为可以使用简单的容器配置轻松测试这种情况:在容器中同时运行被测程序和“本地主机”服务,您可以随机更新容器的.network配置来模拟连接问题。
You can use a reverse proxy like Fiddler and block all requests coming from this application to localhost.您可以使用像 Fiddler 这样的反向代理并阻止所有从该应用程序到本地主机的请求。
If I understood what you mean then this will do: To create a rule, select the Inbound Rules or Outbound Rules category at the left side of the window and click the Create Rule link on the right side.如果我理解您的意思,那么这样做:要创建规则,select window 左侧的入站规则或出站规则类别,然后单击右侧的创建规则链接。 The Windows firewall offers four types of rules: Program – Block or allow a program.
Windows 防火墙提供四种类型的规则: 程序 – 阻止或允许程序。 Port – Block or allow a port, port range, or protocol.
端口 – 阻止或允许端口、端口范围或协议。
if you are using a third party anti-virus solution with a built-in firewall, go to the firewall option and black list/disable/prevent inte.net access to your app如果您使用带有内置防火墙的第三方防病毒解决方案,go 到防火墙选项和黑名单/禁用/阻止 inte.net 访问您的应用程序
Otherwise, disabling your firewall will not stop any access, as it will allow inbound and outbound traffic.否则,禁用防火墙不会阻止任何访问,因为它会允许入站和出站流量。 you can prevent specific ports but disabling the firewall wall will not only do what mentioned before but it will also leave your device vulnerable for online threatts
您可以阻止特定端口,但禁用防火墙墙不仅会执行前面提到的操作,还会使您的设备容易受到在线威胁
Try these 3 simple steps.试试这 3 个简单的步骤。
netstat -ano |
网络统计-ano | findstr:
查找字符串:
eg (if your localhost is listening at port 3900 the command will be as follow;例如(如果您的本地主机正在侦听端口3900 ,则命令如下;
netstat -ano |
网络统计-ano | findstr:3900
查找字符串:3900
the result will be shown on cmd console, the last column is PID (Process id) We will just kill that process which will eventually stop the localhost server to listen any request from any source.结果将显示在 cmd 控制台上,最后一列是 PID(进程 ID)我们将终止该进程,最终停止本地主机服务器以侦听来自任何来源的任何请求。
taskkill /PID /F
taskkill /PID /F
< PID > that you will get from above command. < PID >你将从上面的命令中得到。
in this case, only the localhost will stop it's service, but you application will keep communicating to outer.network, inte.net.在这种情况下,只有本地主机会停止它的服务,但您的应用程序将继续与 outer.network、inte.net 通信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.