centos7找不到iptables的解決辦法:1、寫一條iptables命令配置防火墻規則;2、通過service iptables save進行保存;3、執行service iptables restart命令重啟即可。
本文操作環境: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 啟動iptables
最后 systemctl start iptables 打開iptables
大功告成
試試service iptables save
推薦教程:《centos教程》
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END