Iptables Save


centos 7 中沒有iptables 和service iptables save 指令使用失敗

1.任意運行一條iptables防火牆規則配置命令:

iptables -P OUTPUT ACCEPT  

2.對iptables服務進行保存:

service iptables save  

如果上述命令執行失敗報出:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

解決方法:
#systemctl stop firewalld               關閉防火牆

#systemctl disable firewalld.service        #禁止firewall開機啟動
#yum install iptables-services            安裝或更新服務
#systemctl enable iptables                啟動iptables
# systemctl start iptables                  打開iptables

#service iptables save                      保存

3.重啟iptables服務:

service iptables restart

執行完畢之后/etc/syscofig/iptables文件就有了

成品例句

iptables –A INPUT –s 192.168.0.188 –p tcp  --dport 80 –j ACCEPT

來自188的tcp 80端口放行

iptables –A OUTPUT –d 192.168.0.188 –p tcp  --dport 80 –j ACCEPT

傳輸給188ip的tcp的80端口放行

 

丟棄默認鏈連接

#iptables -P INPUT DROP                                            

#iptables -p OUTPUT DROP                            

#iptables -P FORWARD DROP

 

 

 

管理規則

            -A:附加一條規則,添加豐鏈的尾部

            -I CHAIN [NUM]:插入一條規則插入為對應CHAIN上的第NUM條

            -D CHAIN [NUM]:刪除指定鏈中的第NUM規則

            -R CHAIN [NUM]:替換指定的規則

管理鏈

            -F [CHAIN]清空指定規則鏈,如果省略CHAIN則可買實現刪除對應的所有鏈

            -P CHAIN:設定指定鏈默認策略

            -N:自定義一個新的空鏈

            -X:刪除一個自定義的空鏈

            -Z:置零指定鏈中所有規則的計數器

            -E:重命名自定義的鏈

查看類:

            -L :顯示指定表中的規則

            -n:以數字顯示主機換

            -x:顯示計數器的精確值

            -v:顯示詳細信息

            --line-numbers:顯示規則號碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM