失落的紀錄

2013-08-31

iptables簡易設定說明

分類: Llinux,系統相關 — 番茄 @ 22:29

1.查看本機關於IPTABLES的設置情況
# iptables -L -n

2.清除原有規則
# iptables -F 清除預設表filter中的所有規則鏈的規則
# iptables -X 清除預設表filter中使用者自定鏈中的規則

3.保存設置規則(因配置隨系統重啟而失效)
# /etc/rc.d/init.d/iptables save
保存規則到/etc/sysconfig/iptables文件中, 也可手工編輯該文件.

4.設定預設規則,不允許任何封包通過.
# iptables -p INPUT DROP
# iptables -p OUTPUT DROP
# iptables -p FORWARD DROP


5.增加規則
# iptables -A INPUT -p tcp –dport 22 -j ACCEPT
# iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT

6.開啟22端口, 允許SSH登錄, 如開啟80端口:
# iptables -A INPUT -p tcp –dport 80 -j ACCEPT
# iptables -A OUTPUT -p tcp –sport 80 -j ACCEPT

7.禁止某個IP訪問
# iptables -I INPUT -s x.x.x.x -j DROP

也可進行更細緻的設置, 如只允許192.168.1.14的機器進行SSH連接:
# iptables -A INPUT -p tcp –dport 22 -s 192.168.1.14 -j ACCEPT
如果要允許或限制一段IP地址可用192.168.1.0/24 表示192.168.1.1-255端的所有IP.

8.防止同步包洪水(Sync Flood)
# iptables -A FORWARD -p tcp –syn -m limit –limit 1/s -j ACCEPT

9.防止各種端口掃瞄
# iptables -A FORWARD -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j ACCEPT

10.Ping 洪水攻擊(Ping of Death)
# iptables -A FORWARD -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT

無迴響

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress