Ubuntu16.04 配置 iptables
阿新 • • 發佈:2020-12-26
技術標籤:linux
一、檢查是否已安裝防火牆
1. whereis iptables
2\安裝
apt-get install iptables
vi /etc/iptables.rules
iptables-restore < /etc/iptables.rules
規則裡面。
#iptables-save v1.4.21 on Wed Nov 4 16:53:19 2020 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [26885783:13781698742] -A INPUT -s 172.0.0.9/32 -p tcp -m multiport --dports 300 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 322 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT # Completed on Wed Nov 4 16:53:19 2020 # # Generated by iptables-save v1.4.21 on Wed Nov 4 16:53:19 2020 # *raw # :PREROUTING ACCEPT [66722:51427761] # :OUTPUT ACCEPT [71861:38356054] # :HYFORT_CHAIN - [0:0] # -A PREROUTING -j HYFORT_CHAIN # COMMIT # # Completed on Wed Nov 4 16:53:19 2020
檢視規則:
iptables -nvL
刪除第一條
iptables -D INPUT 1
問題一:
新增某一個ip【下載是80埠】
iptables -I INPUT -p tcp -s 10.17.30.10 -m multiport --dports 80 -j ACCEPT
---------------------------------------------------------------------------------------------------
問題二:
清除所有規則
iptables -t filter -F
沒有關掉iptables的命令列嗎。
-----------------------------------------------------------------------
問題三:
上傳是 21埠和3000-4000埠的開通
iptables -I INPUT -p tcp -s 10.10.10.10 -m multiport --dports 3000:4000 -j ACCEPT
問題四:啟動iptables的規則
iptables-restore < /etc/iptables.rules