deepin firewalld#
Deepin 是一款基於 Debian 的 Linux 發行版。
其默認防火牆是 iptables。與 firewalld 不同,iptables 是一種基於規則的防火牆,需要手動配置規則進行端口的開放和關閉。
您可以使用以下命令來查看當前 iptables 的規則:
sudo iptables -L
您可以在 /etc/iptables/rules.v4 文件中編輯規則。例如,如果您要允許 80 端口的訪問,您可以添加以下規則:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
安裝 firewalld 可以讓您更容易地管理防火牆規則。您可以使用以下命令安裝 firewalld:
sudo apt install firewalld
之後,您可以使用以下命令啟動和停止 firewalld 服務:
sudo systemctl start firewalld
sudo systemctl stop firewalld
您可以使用以下命令將 80 端口添加到 firewalld 的規則中:
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --reload
注意,firewalld 的默認規則是拒絕所有入站連接。
在 Deepin 上選擇使用 iptables 還是 firewalld 取決於您的個人偏好和需要。如果您經常需要添加、刪除或更改防火牆規則,則 firewalld 可能更加適合您。
deepin 查看端口開放列表#
在 Deepin 上,您可以使用以下命令來查看當前打開的端口列表:
- 使用 netstat 命令查看
sudo netstat -tunlp
上述命令將顯示所有當前打開的端口及其關聯的進程。
- 使用 lsof 命令查看
sudo lsof -i -P -n | grep LISTEN
上述命令將列出所有當前處於監聽狀態的端口及其關聯進程的詳細信息。
- 使用 iptables 命令查看
sudo iptables -L -n -v
該命令將列出 iptables 規則表中的所有規則,其中包括打開的端口。
注意,如果防火牆正在攔截某個端口,則無論使用哪個命令,都不會顯示該端口。如果您想允許某個端口,您需要修改防火牆配置,如添加允許端口的規則。
Deepin iptables 查看端口開放列表#
在 Deepin 上,您可以使用以下命令查看當前打開的端口:
sudo iptables -L -n -v --line-numbers | grep ACCEPT
該命令將列出 iptables 規則表中的所有已允許的端口及其規則信息。
另外,如果您想查看某個具體端口是否已經打開,可以使用以下命令:
sudo iptables -L -n -v --line-numbers | grep <port_number>
上述命令將列出 iptables 規則表中與指定端口相關的規則信息。
請注意,Iptables 是一種基於規則的防火牆,需要手動配置規則進行端口的開放和關閉。如果您發現某個端口沒有打開,您需要手動添加相應的規則,如下例:
sudo iptables -A INPUT -p tcp --dport <port_number> -j ACCEPT
上述命令將允許 TCP 端口 <port_number> 上的所有數據包進入系統。
為了使規則永久保留,您需要將規則保存到防火牆配置中:
sudo service iptables save
保存規則後,如果系統重新啟動,這些規則將會自動加載。
deepin 卸載 firewalld#
在 Deepin 中卸載 Firewalld,您可以按照以下步驟進行:
- 停止並禁用 Firewalld 服務:
sudo systemctl stop firewalld
sudo systemctl disable firewalld
- 移除 Firewalld:
sudo apt remove firewalld
- (可選)移除 Firewalld 的配置文件:
sudo rm -rf /etc/firewalld
請注意,在卸載 Firewalld 後,Deepin 將自動恢復為默認的 iptables 防火牆。如果您想使用其他防火牆軟件進行替代,請隨時安裝和配置您選擇使用的軟件。