Catalogue
A Ruby 30-Second Cooking Script to Fetch IPs Accessed from Within Japan

A Ruby 30-Second Cooking Script to Fetch IPs Accessed from Within Japan

🌐 日本語で読む

First, the Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ git clone https://gist.github.com/kenzo0107/714ece62cf6450386ff0fb16fd5b777a
$ cd 714ece62cf6450386ff0fb16fd5b777a
$ ruby getJapanIP.rb

1.0.16.0
1.0.64.0
1.1.64.0
1.5.0.0
...
(omitted)
...
223.223.164.0
223.223.208.0
223.223.224.0

Overview

I created this because of a request:
there were separate Japanese and overseas versions of a URL,
and when someone accessed the overseas version from within Japan,
they wanted to redirect them to the Japanese version of the site.

Using this script, I set up the redirect in the .htaccess and so on for the overseas site.

That’s all.

kenzo0107

kenzo0107