Ubuntu Dektop의 열린 포트는 시스템 외부에서 액세스할 수 없습니다.

Ubuntu Dektop의 열린 포트는 시스템 외부에서 액세스할 수 없습니다.

나는 Ubuntu Dektop 컴퓨터에서 포트 9591을 열기 위해 0 0.0.0.0:9591을 사용합니다.

$ netstat -tulpn | grep 9591
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:9591            0.0.0.0:*               LISTEN      -

localhost와 마찬가지로 컬 호출에 :9591/api를 사용하면 127.0.0.1이 시스템 내에서 잘 작동합니다. IP 주소를 사용하려고 해도 컴퓨터 내에서는 컬이 잘 작동합니다.

Ubuntu 데스크탑 컴퓨터를 호스팅하는 SSH도 네트워크에서 잘 작동합니다.

$ curl -vvv http://<IP>:9591/
*   Trying <IP>:9591...
* Connected to <IP> (<IP>) port 9591 (#0)
> GET / HTTP/1.1
> Host: <IP>:9591
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.3 Python/2.7.18
< Date: Fri, 13 Jan 2023 13:50:39 GMT
< Access-Control-Allow-Origin: *
< Content-Length: 58
< Content-Type: application/json
<
* Closing connection 0
request received.

네트워크 내의 외부 시스템에서 :9591/api를 사용하여 컬 호출을 시도하면 다음과 같이 실패합니다.

$  curl -vvv http://<IP>:9591/
*   Trying <IP>...
* TCP_NODELAY set
* connect to <IP> port 9591 failed: Connection timed out
* Failed to connect to <IP> port 9591: Connection timed out
* Closing connection 0
curl: (7) Failed to connect to <IP> port 9591: Connection timed out

제안해주세요.

답변1

ufw를 사용하여 포트에 대한 외부 액세스를 허용합니다.

$ sudo ufw allow 9591

관련 정보