溫馨提示×

centos7防火墻怎么設置ip白名單

小億
524
2023-11-07 15:47:48
欄目: 編程語言

在CentOS 7上設置IP白名單,可以使用firewalld防火墻來實現(xiàn)。下面是設置IP白名單的步驟:

  1. 檢查firewalld防火墻是否已安裝并運行:

    systemctl status firewalld
    

    如果沒有安裝,可以使用以下命令安裝:

    yum install firewalld
    

    然后啟動firewalld:

    systemctl start firewalld
    
  2. 添加IP到白名單:

    firewall-cmd --permanent --add-source=IP地址
    

    將IP地址替換為要添加的實際IP地址??梢远啻芜\行此命令來添加多個IP地址。

  3. 重新加載防火墻規(guī)則:

    firewall-cmd --reload
    
  4. 驗證IP是否已添加到白名單:

    firewall-cmd --permanent --list-sources
    

    將顯示已添加到白名單的IP地址列表。

  5. 如果要刪除已添加的IP地址,可以使用以下命令:

    firewall-cmd --permanent --remove-source=IP地址
    

注意:以上命令均需要使用root權限執(zhí)行。設置完成后,firewalld將允許來自添加到白名單的IP地址的流量通過防火墻。

0