Skip to content
matveynator edited this page Apr 29, 2023 · 5 revisions

Cкачиваем базу geoip с помощью gurl или curl:

gurl https://geoip.site/download/IP2Location/GeoIP.acl > /etc/bind/GeoIP.acl
curl https://geoip.site/download/IP2Location/GeoIP.acl > /etc/bind/GeoIP.acl

Меняем настройки Bind9:

include "/etc/bind/GeoIP.acl";
  

view "russia" {
        match-clients { RU; };

        zone "matveynator.ru" {
                type master;
                file "/var/lib/bind/matveynator.ru.hosts-russia";
        };

        include "/etc/bind/named.conf.local";
};

view "world" {
        match-clients { any; };

        zone "matveynator.ru" {
                type master;
                file "/var/lib/bind/matveynator.ru.hosts-world";
        };

        include "/etc/bind/named.conf.local";
};

Проверка:

dig +short test.matveynator.ru

получаем ответ 127.0.0.1 или 127.0.0.2 в зависимости от региона запроса (из России или из другой страны)

Clone this wiki locally