Trang chủ » Diễn Đàn » Hỏi đáp Tin học » Hỏi đáp về Linux/UNIX » Cần giúp đỡ về Crip Iptables của mình
Chủ đề đã bị khóa, bạn không thể xóa, sửa hay trả lời trong chủ đề này!
|
|
|---|
|
0
Cho mình hỏi là sau khi mình chạy Crip này hoàn toàn ko bị lỗi gì cả, mình cũng dùng lệnh iptables-save lưu cấu hình lại rồi nhưng sau đó test thử thì thấy không nhúc nhích gì cả. Cũ thể là mình thử ping từ server ra ngoài và ping từ ngoài vào server nhưng vẫn bình thường ko thấy ảnh hưởng gì từ iptables cả. Sau đó mình thử loggin ssh qua putty 3 lần sai thử xem có block ip và hạn chế số lần loggin ko nhưng vẫn bình thường. Do mình mới vào lĩnh vực này nên mong được các bậc tiền bối ra tay giúp đỡ. Chân thành cảm ơn!
#Cài đặt iptables $ apt-get install iptables #Xóa tất cả $ iptables -X # Zero all packets and coynters $ iptables -Z # Xóa các luật tồn tại trong 1 chain $ iptables -F # Đặt chính sách mặc định cho các chain $ iptables -P INPUT ACCEPT $ iptables -P OUTPUT ACCEPT $ iptables -P FORWARD DROP # Cài đặt thiết bị loopback $iptables -A INPUT -i lo -j ACCEPT $iptables -A OUTPUT -o lo -j ACCEPT # Chấp nhận tất cả các lưu lượng kết nối đến liên quan tới các kết nối hiện tại đã được cho phép. $ iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT # Chấp nhận kết nối mới $ iptables -A INPUT -i eth0 -m state --state NEW -j ACCEPT # Chống kiểu tấn công Syn Flood (giới hạn trong 1s chỉ nhận 5 yêu cầu kết nối TCP) $ iptables -A INPUT -p tcp --syn -m limit --limit 2/s limit-burst 3 -i eth0 -j ACCEPT # Hệ thống được phép thực hiện lệnh ping ra ngoài $ iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT $ iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT # Giới hạn chỉ nhận một gói tin ping trong 1 giây $ iptables -A INPUT -p icmp --icmp-type echo-request -m state --state NEW -m limit --limit 1/s -i eth0 -j ACCEPT # Drop các gói phân mảnh (tấn công Teardrop) $ iptables -A INPUT -p tcp -f -j DROP $ iptables -A INPUT -p udp -f -j DROP $ iptables -A INPUT -p icmp -f -j DROP #Chống Port Scanner # Chống Xmas Scan (gửi gói tin với ba cờ được thiết lập FIN, URG, PSH) $ iptables -A INPUT -m state --state NEW -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP $iptables -A INPUT -m state --state NEW -p tcp --tcp-flags ALL ALL -j DROP (Xmas) $ iptables -A INPUT -m state --state NEW -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP (Xmas – PSH) # Chống Null Scan (tắt tất cả cờ) $ iptables -A INPUT -m state --state NEW -p tcp --tcp-flags ALL NONE -j DROP # SYN/RST $ iptables -A INPUT -m state --state NEW -p tcp --tcp-flags SYN,RST SYN,RST -j DROP # SYN/FIN $ iptables -A INPUT -m state --state NEW -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP # Block Dos – Ping of Death $ iptables -A INPUT -p icmp --icmp-type echo-request -m length --length 60:65535 -j ACCEPT # Block DDoS – Smurf $ iptables -A INPUT -m pkttype --pkt-type broadcast -j DROP $iptables -A INPUT -p icmp --icmp-type echo-request -m pkttype --pkt-type broadcast -j DROP $ iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 3/s -j ACCEPT #Block DDoS – UDP Flood $ iptables -A INPUT -p udp --dport 7 -j DROP $ iptables -A INPUT -p udp --dport 19 -j DROP # Block DDoS – SMBnuke $ iptables -A INPUT -p udp --dport 135:139 - j DROP $ iptables -A INPUT -p udp --dport 135:139 - j DROP # Block DDoS – Fraggle $ iptables -A INPUT -p udp -m pkttype --pkt-type broadcast -j DROP $ iptables -A INPUT -p udp -m limit --limit 3/s -j ACCEPT # Allow Sip Connections $ iptables -A INPUT -p udp -i eth0 --dport 5060 -m udp -j ACCEPT $ iptables -A INPUT -p tcp -i eth0 --dport 5060 -m tcp -j ACCEPT # Allow wedmin and usermin remote to your system $ iptables -A INPUT -p udp -i eth0 --dport 10000:20000 -m udp -j ACCEPT # Allow incoming DNS requests $iptables -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT $iptables -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT # Accept answers and established connections for outgoing traffic $ iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT $ iptables -A OUTPUT –p ALL -j ACCEPT # Thiết lập iptables chỉ cho phép host 192.168.1.39 kết nối tới dịch vụ SSH. Sau ba lần đăng nhập thất bại, iptables chỉ cho phép host đăng nhập lại sau từng phút $ iptables -A INPUT -p tcp -s 192.168.1.39 -m state --syn --state NEW --dport 2200 -m limit --limit 2/minute --limit-burst 3 -j ACCEPT $ iptables -A INPUT -p tcp -s 192.168.1.39 -m state --syn --state NEW --dport 2200 -j DROP |
