首頁 > 運維 > CentOS > 主體

centos7找不到iptables怎麼辦

藏色散人
發布: 2022-01-11 11:38:42
原創
4498 人瀏覽過

centos7找不到iptables的解決方法:1、寫一條iptables指令設定防火牆規則;2、透過service iptables save進行儲存;3、執行service iptables restart指令重啟即可。

centos7找不到iptables怎麼辦

本文操作環境:CentOS 7系統、Dell G3電腦。

centos7找不到iptables怎麼辦?

centos7下找不到iptables檔?

最近在centos7下,搭建ftp服務,按照步驟一步一步來,發現etc/sysconfig/iptables這個檔案不存在,然後去找解決方案,

解決方法:

##1. 隨便寫一條iptables命令配置個防火牆規則。如:iptables -P OUTPUT ACCEPT。

[root@iZ23gx7o02aZ /]# cd /etc/sysconfig/
[root@iZ23gx7o02aZ sysconfig]# iptables -P OUTPUT ACCEPT
登入後複製

2. service iptables save進行儲存。

[root@iZ23gx7o02aZ sysconfig]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iZ23gx7o02aZ sysconfig]# ls
atd         firstboot         iptables-config  networking       readonly-root  sshd
auditd      grub              irqbalance       network-scripts  rhn            sysstat
authconfig  htcacheclean      kdump            ntpd             rngd           sysstat.ioconf
cbq         httpd             kernel           ntpdate          rsyslog        system-config-firewall
clock       i18n              keyboard         prelink          sandbox        system-config-firewall.old
console     init              modules          quota_nld        saslauthd      udev
cpuspeed    ip6tables-config  netconsole       raid-check       selinux
crond       iptables          network          readahead        smartmontools
[root@iZ23gx7o02aZ sysconfig]#
登入後複製

3. service iptables restart指令重啟:

[root@iZ23gx7o02aZ sysconfig]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@iZ23gx7o02aZ sysconfig]#
登入後複製

但是在service iptables save進行儲存操作時,提示save指令不存在,於是繼續找解決方案,

#首先不管防火牆有沒有關都使用systemctl stop firewalld 關閉防火牆

然後使用yum install iptables-services 安裝或更新服務

再使用systemctl enable iptables 啟動或更新服務

再使用systemctl enable iptables 啟動#iptables

最後systemctl start iptables 開啟iptables

大功告成

試試service iptables save

推薦教學:《centos教學

》## #

以上是centos7找不到iptables怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!