centos 防火牆配置

  • CentOS 配置防火牆操作實例(啓、停、開、閉端口)
  • 關閉firewall安裝iptables並配置
    CentOS 7.0默認使用的是firewall作爲防火牆,這裏改爲iptables防火牆。
    1、關閉firewall:
    [root@localhost ~]# systemctl stop firewalld.service #停止firewall
    注:(centos7之前的命令形式爲:server firewalld stop)
    [root@localhost ~]# systemctl disable firewalld.service #禁止firewall開機啓動
    注:(centos7之前的命令形式爲:chkconfig firewalld off)
    這裏寫圖片描述
    2、安裝iptables防火牆
    [root@localhost ~]# yum install -y iptables-services
    [root@localhost ~]# vi /etc/sysconfig/iptables
    #編輯防火牆配置文件
    這裏寫圖片描述
    [root@localhost ~]# systemctl restart iptables.service #重啓防火牆使配置生效
    [root@localhost ~]# systemctl enable iptables.service #設置防火牆開機啓動
  • 防火牆的基本操作命令:
    查詢防火牆狀態:
    [root@localhost ~]# service iptables status
    停止防火牆:
    [root@localhost ~]# service iptables stop
    啓動防火牆:
    [root@localhost ~]# service iptables start
    重啓防火牆:
    [root@localhost ~]# service iptables restart
    永久關閉防火牆:
    [root@localhost ~]# chkconfig iptables off
    永久關閉後啓用:
    [root@localhost ~]# chkconfig iptables on
    編輯/etc/sysconfig/iptables文件。我們實例中要打開8000端口和8888端口
    用編輯器打開/etc/sysconfig/iptables
    命令:[root@localhost ~]# vi /etc/sysconfig/iptables
    保存/etc/sysconfig/iptables文件,並在終端執行
    [root@localhost ~]# service iptables restart
    這裏寫圖片描述
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章