mkdir /root/src/

 

cd /root/src/

 

wget http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/patch-o-matic-ng-20080521.tar.bz2

 

wget ftp://ftp.pbone.net/mirror/vault.centos.org/5.8/os/SRPMS/iptables-1.3.5-9.1.el5.src.rpm

 

rpm -ivh /rpm -ivh iptables-1.3.5-9.1.el5.src.rpm

 

cd /usr/src/redhat/SOURCES/

 

bunzip2 iptables-1.3.5.tar.bz2

 

tar -xvf iptables-1.3.5.tar 

 

ln -s /usr/src/redhat/SOURCES/iptables-1.3.5 /usr/src/iptables

 

ln -s /usr/src/kernels/`uname -r`-x86_64 /usr/src/linux

 

cd /root/src/patch-o-matic-ng-20080521

./runme --download
엔터 엔터

./runme geoip
엔터 엔터 y

 

cd /usr/src/iptables/

make

 

cp extensions/libipt_geoip.so /lib64/iptables/

 

 cd /usr/src/linux/

 

make oldconfig

make modules_prepare

mv /usr/src/linux/net/ipv4/netfilter/Makefile /usr/src/linux/net/ipv4/netfilter/Makefile.orig

 

vi /usr/src/linux/net/ipv4/netfilter/Makefile 

(열어서 아래 내용 저장)

obj-m := ipt_geoip.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules

 

 

make M=/usr/src/linux/net/ipv4/netfilter

 

cp /usr/src/linux/net/ipv4/netfilter/ipt_geoip.ko /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/

chmod 744 /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/ipt_geoip.ko

depmod -a

modprobe ipt_geoip

 

mkdir /var/geoip ; cd /var/geoip ; wget http://people.netfilter.org/peejix/geoip/tools/csv2bin-20041103.tar.gz ; tar -xvzf csv2bin-20041103.tar.gz

cd csv2bin ; make

 

그다음 https://xinet.kr/?p=2711 여기 나온대로 maxmind 로그인 후 csv 파일 다운로드

 

csv 받으면 옛날 방식의 csv로 컨버팅 해야 함

####

GeoLite2-Country-CSV.zip 파일은 기존 csv 파일과 양식이 달라서 아래와 같이 컨버팅이 필요함

wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip

unzip -o -j GeoLite2-Country-CSV.zip '*/GeoLite2-Country-Blocks*' ##국가코드 DB:csv 파일 다운로드후 압축 풀기

wget http://download.geonames.org/export/dump/countryInfo.txt ##국가코드

https://github.com/mschmitt/GeoLite2xtables 여기 들어가서 20_convert 컨버팅 하는거 다운로드 ##컨버팅 스크립트

chmod 755 20_geo_convert.pl

/usr/bin/cpan -i NetAddr::IP ##컨버팅시 perl에 use NetAddr::IP; 라는 모듈을 사용하는 대부분 설치 안돼있어서 cpan으로 설치해야함

cat GeoLite2-Country-Blocks-IPv{4,6}.csv | ./geo_convert.pl CountryInfo.txt > GeoIPCountry.csv ##컨버팅

cat ./GeoLite2-Country-Blocks-IPv{4,6}.csv | ./20_convert_geolite2  ./countryInfo.txt  > GeoIP-legacy.csv

 

csv 옛날껄로 컨버팅 한다음 

 

./csv2bin GeoIP-legacy.csv 로 컨버팅 하고 

cp -ra geoipdb.* /var/geoip/

 

이러면 완료

'job > linux' 카테고리의 다른 글

systemd: Created slice libcontainer_number_systemd_test_default.slice.  (0) 2022.07.11
gitlab - elasticsearch intergration  (0) 2021.02.16
pgsql 해킹 프로세스  (0) 2019.12.30
tls 1.1 지원 중단  (0) 2019.12.09
nginx + php-fpm 취약점  (0) 2019.10.29

+ Recent posts