iptableを利用してファイアウォールルールを設定するサンプル

# 192.168.1.69でfirewallを設定
iptables -A INPUT -p tcp –dport 80 -m time ! –weekdays Mon -m string –algo kmp ! –string “admin" -m limit –limit 100/second -j ACCEPT

# CentOSで「/etc/sysconfig/iptables-config」のIPTABLES_MODULESを変更
iptables -A INPUT -p tcp –dport 21 -m time –weekdays 1,2,3,4 –start-time 09:30 –stop-time 18:00 -m limit –climit-rate 5/minute –modprobe="modprobe nf_conntrack_ftp" -j ACCEPT
iptables -A INPUT -p tcp –dport 22 -m iprange –src-range 192.168.1.1-192.168.10.100 -m limit –limit-rate 2/minute -j ACCEPT

iptables -A INPUT -p tcp –tcp-flags ALL ALL -j DROP
iptables -A INPUT -p tcp –tcp-flags ALL NONE -j DROP

# Inputルールに入れる
iptables -I INPUT 1 -m state –state ESTABLISED,RELATED -j ACCEPT

iptables -A OUTPUT -s 192.168.1.69 -p icmp –icmp-type 8 -j ACCEPT

iptables -P INPUT DROP
iptables -P OUTPUT DROP

iptables -I OUTPUT 1 -m state –state ESTABLISED,RELATED -j ACCEPT

 

Linux

Posted by arkgame