Ubuntu 內建使用 UFW (Uncomplicated Firewall) 作為防火牆管理工具, 一般情況下都會開啟防火牆, 但有些特殊情況, 例如測試環境需要關閉防火牆作測試, 或者對網路設定進行除錯等。
以下是在 Ubuntu 18.04 關閉防火牆的方法。
首先檢查目前防火牆是否已經開啟, 執行以下指令:
$ sudo ufw status
防火牆預設是關閉, 會輸出:
Status: inactive
如果防火牆已經開啟了, 會輸出 active:
Status: active
如果需要關閉防火牆, 執行以下指令:
Disabling the Firewall
$ sudo ufw disable
Firewall stopped and disabled on system startup
Firewall stopped and disabled on system startup
關閉防火牆後, 要再次開啟防火牆, 執行以下指令開啟:
$ sudo ufw enable
這時會出現以下詢問句:
Command may disrupt existing ssh connections. Proceed with operation (y|n)?
按 “y” 確認後, 防火牆會開啟, 並有以下輸出:
Firewall is active and enabled on system startup