« 国別IP | メイン | javascript中にアサインでエスケープ »
2008年06月17日
ほぼ日本からのみアクセス許可
以下のスクリプトをつくた
rm -f delegated-apnic-latest
wget -q ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest
if [ -f "delegated-apnic-latest" ];then
cp htaccess_org.txt .htaccess_edit
echo deny from all >> .htaccess_edit
cat delegated-apnic-latest | grep ipv4 |grep "|JP|"| awk -F "|" '\
$5==128 {print "allow from "$4"/25"} \
$5==256 {print "allow from "$4"/24"} \
$5==512 {print "allow from "$4"/23"} \
$5==1024 {print "allow from "$4"/22"} \
$5==2048 {print "allow from "$4"/21"} \
$5==4096 {print "allow from "$4"/20"} \
$5==8192 {print "allow from "$4"/19"} \
$5==16384 {print "allow from "$4"/18"} \
$5==32768 {print "allow from "$4"/17"} \
$5==65536 {print "allow from "$4"/16"} \
$5==131072 {print "allow from "$4"/15"} \
$5==262144 {print "allow from "$4"/14"} \
$5==524288 {print "allow from "$4"/13"} \
$5==1048576 {print "allow from "$4"/12"} \
$5==2097152 {print "allow from "$4"/11"} \
$5==4194304 {print "allow from "$4"/10"} \
$5==8388608 {print "allow from "$4"/9"} \
$5==16777216 {print "allow from "$4"/8"} \
$5==33554432 {print "allow from "$4"/7"}' >> .htaccess_edit
echo "allow from 133.0.0.0/8" >> .htaccess_edit
echo "
echo "allow from all" >> .htaccess_edit
echo "
mv .htaccess_edit .htaccess
fi
133は日本のIP管理の下にないらしい。他にもあるが
詳細がわからないので割愛
↓参考
http://www.nic.ad.jp/ja/ip/hr/
投稿者 muuming : 2008年06月17日 18:46