OS:CentOS45
まず、linuxのファイヤーウォール(firewall)の種類には
何種類かあるらしい。
なかでも、selinuxの機能を使用するのがもっとも安全しかし
設定が面倒なようです。
ファイアーウォール、ファイヤーウォール、ファイヤウォール
ファイアウォールとも言う。
今回設定は、iptablesを使用します。
hosts.allow、hosts.denyの設定は行いません。
参考URL:http://www.rivo.mediatti.net/~okutama/iptables.htm
・/etc/sysconfig/iptablesを編集。
・iptablesのリブートでしようできました。
vi /etc/sysconfig/iptables ##すべて追記しました。 ##ルール すべての端末を通し、192.168.1.0/24を拒否したい場合 # Generated by iptables-save v1.2.11 on Wed Jan 7 14:04:33 2009 *nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT # Completed on Wed Jan 7 14:04:33 2009 # Generated by iptables-save v1.2.11 on Wed Jan 7 14:04:33 2009 *mangle :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT # Completed on Wed Jan 7 14:04:33 2009 # Generated by iptables-save v1.2.11 on Wed Jan 7 14:04:33 2009 *filter :FORWARD ACCEPT [0:0] :INPUT ACCEPT [0:0] :OUTPUT ACCEPT [0:0] # TEST FILLETER ここが肝!! -A INPUT -s 192.168.1.0/255.255.255.0 -j REJECT COMMIT # Completed on Wed Jan 7 14:04:33 2009
・/etc/sysconfig/iptablesを編集。
・iptablesのリブートでしようできました。
##すべて追記しました。 ##SSHとIDENT以外の外部インターフェースへの接続を遮断する # Completed on Wed Jan 7 13:54:27 2009 # Generated by iptables-save v1.2.11 on Wed Jan 7 13:54:27 2009 *filter :FORWARD ACCEPT [0:0] :INPUT DROP [0:0] :OUTPUT ACCEPT [0:0] # Accept traffic from internal interfaces -A INPUT ! -i eth0 -j ACCEPT # Accept traffic with the ACK flag set -A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT # Allow incoming data that is part of a connection we established -A INPUT -m state --state ESTABLISHED -j ACCEPT # Allow data that is related to existing connections -A INPUT -m state --state RELATED -j ACCEPT # Accept responses to DNS queries -A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT # Accept responses to our pings -A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT # Accept notifications of unreachable hosts -A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT # Accept notifications to reduce sending speed -A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT # Accept notifications of lost packets -A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT # Accept notifications of protocol problems -A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT # Allow connections to our SSH server -A INPUT -p tcp -m tcp --dport ssh -j ACCEPT # Allow connections to our IDENT server -A INPUT -p tcp -m tcp --dport auth -j ACCEPT COMMIT # Completed on Wed Jan 7 13:54:27 2009
reboot方法
/etc/init.d/iptables restart
アクセス数| - |