安装 ufw 后无法通过 python 脚本在 443 上发出请求

Unable to make requests on 443 via python script after ufw installed

我已设置 ufw 以允许 443 上的流量,这是规则

sudo ufw 状态 状态:活跃

To                         Action      From
--                         ------      ----
443/tcp                    ALLOW       Anywhere
443 (v6)                   ALLOW       Anywhere (v6)

443/tcp                    ALLOW OUT   Anywhere
443/tcp (v6)               ALLOW OUT   Anywhere (v6)

我正在编写一个简单的脚本来获取

的响应代码

https://google.com

这是堆栈跟踪。

File "/home/username/.local/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/username/.local/lib/python2.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f8633926350>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

知道出了什么问题吗?

我使用

启用了 443
sudo ufw allow out https

根据错误消息,似乎是 DNS 问题。尝试允许 DNS 请求