Last active
January 9, 2016 00:22
-
-
Save dseg/69c9f1632b5da7ce672d to your computer and use it in GitHub Desktop.
Bind 9.10のGeoIP機能を使って、リクエスト元に近いサーバのIPを返す ref: http://qiita.com/dseg/items/db3b66f824cfcb12f065
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ httping -c 3 qiita.com | |
PING qiita.com:80 (/): | |
connected to 54.248.127.202:80 (386 bytes), seq=0 time=579.29 ms | |
connected to 54.248.127.202:80 (386 bytes), seq=1 time=530.49 ms | |
connected to 54.248.127.202:80 (386 bytes), seq=2 time=533.82 ms | |
--- http://qiita.com/ ping statistics --- | |
3 connects, 3 ok, 0.00% failed, time 4645ms | |
round-trip min/avg/max = 530.5/547.9/579.3 ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ named -V | sed -r 's/ +/\n/g'|grep geoip | |
'--with-geoip=/usr' | |
# OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ named -V | sed -r 's/ +/\n/g'|grep geoip | |
'--with-geoip=/usr' | |
# OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ sudo apt-get install geoip-database | |
or | |
$ sudo apt-get install geoip-database-contrib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geoip [db database] field value | |
# examples | |
geoip country US; | |
geoip country JAP; | |
geoip db country country Canada; | |
geoip db region region WA; | |
geoip city "San Francisco"; | |
geoip region Oklahoma; | |
geoip postal 95062; | |
geoip tz "America/Los_Angeles"; | |
geoip org "Internet Systems Consortium"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geoip [db database] field value | |
# examples | |
geoip country US; | |
geoip country JAP; | |
geoip db country country Canada; | |
geoip db region region WA; | |
geoip city "San Francisco"; | |
geoip region Oklahoma; | |
geoip postal 95062; | |
geoip tz "America/Los_Angeles"; | |
geoip org "Internet Systems Consortium"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nslookup examples.com 1.2.3.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nslookup examples.com 1.2.3.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view "jp" { | |
match-clients { jp; }; | |
zone "example.com" { | |
type master; | |
file "/etc/bind/example.com.tokyo.zone"; | |
/* 以下略 */ | |
}; | |
}; | |
view "uk" { | |
match-clients { uk; }; | |
zone "example.com" { | |
type master; | |
file "/etc/bind/example.com.london.zone"; | |
/* 以下略 */ | |
}; | |
}; | |
view "other" { | |
zone "example.com" { | |
type master; | |
file "/etc/bind/example.com.other.zone"; | |
/* 以下略 */ | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logging { | |
channel queries_file { | |
file "/var/log/named/queries.log" | |
versions 3 size 5m; | |
severity dynamic; | |
print-time yes; | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
08-Jan-2016 8:45:10.527 client 104.238.171.177#39341 (example.com): view uk: query: example.com IN A + (172.31.22.25) | |
08-Jan-2016 8:49:30.593 client 202.157.182.142#2043 (example.com): view other: query: example.com IN SOA -T (172.31.22.25) | |
08-Jan-2016 8:54:06.839 client 157.192.160.134#40687 (example.com): view jp: query: example.com IN A + (172.31.22.25) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo add-apt-repository ppa:mgrocock/bind9 | |
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 083F021DDC682B55 | |
sudo apt-get up{dat,grad}e -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment