添加防火墙

New-NetFirewallRule -DisplayName "Jupyter Lab (Port 8899)" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8899

-DisplayName "Jupyter Lab (Port 8899)": 给这个规则起一个易于识别的名字。

-Direction Inbound: 表示这是一个“入站”规则(外部访问内部)。

出站就是 -Direction Outbound

-Action Allow: 表示“允许”连接。

-Protocol TCP: 指定协议为 TCP。

-LocalPort 8899: 指定要开放的端口号。

验证规则

Get-NetFirewallRule -DisplayName "Jupyter Lab (Port 8899)"

如果返回了规则的详细信息,就说明配置成功了。

删除规则

Remove-NetFirewallRule -DisplayName "Jupyter Lab (Port 8899)"

无法使用

如果无法使用,就说明权限不够,使用管理员权限再次运行命令。