firewalld firewall-cmd ipset 으로 국가 ip 차단하기
페이지 정보
본문
ㅁ 국가별 ip 목록 가져오기
개별국가의 ip 목록 가져오기 - 예, 중국
# wget http://www.ipdeny.com/ipblocks/data/countries/cn.zone
모든 국가의 ip 목록을 가져오려면 아래와 같이 가져와서 압축을 풀면 된다.
# wget http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz
ㅁ ipset 만들기
# firewall-cmd --permanent --new-ipset=cnlist --type=hash:net --option=family=inet --option=hashsize=4096 --option=maxelem=200000
ㅇ 옵션
--permanent 를 반드시 사용해야만 한다. [P only]
--type 은 반드시 지정을 해 주어야 한다.
--option 은 없어도 된다.
ㅇ 지원가능한 types
# firewall-cmd --get-ipset-types
ㅁ ipset 에 ip 목록 입력하기
# firewall-cmd --permanent --ipset=cnlist --add-entries-from-file=./cn.zone
- 주의 : 여기서도 --permanent 가 반드시 필요하다.
ㅁ 입력한 ipset 확인
# firewall-cmd --permanent --get-ipsets
# firewall-cmd --permanent --info-ipset=cnlist
- 주의 : 여기서도 --permanent 가 반드시 있어야 한다. permanent 한것은 permanent 로만 확인 가능.
ㅁ ipset 을 drop zone 에 적용하기
ㅇ 기존에 있는 zone 들 확인하기
# firewall-cmd --permanent --get-zones
ㅇ drop zone 에 추가하기
# firewall-cmd --permanent --zone=drop --add-source=ipset:cnlist
ㅇ ssh service 를 차단하도록 추가
# firewall-cmd --permanent --zone=drop --add-service=ssh
ㅇ permanent 를 실제 서비스에 적용하기 위해서는 reload 가 필요하다.
# firewall-cmd --reload
시간이 좀 많이 걸린다. 몇분. ip 목록이 많을 수록 시간이 많이 걸리는 듯 하다.
ㅁ ipset 을 drop zone 에서 제거하기
ㅇ 적용되어 있는 소스 확인
# firewall-cmd --permanent --zone=drop --list-sources
ㅇ 소스 제거
# firewall-cmd --permanent --zone=drop --remove-source=ipset:cnlist
ㅁ ipset 삭제
# firewall-cmd --permanent --delete-ipset=cnlist
ㅁ P only
ipset 관련 옵션들은 --permanent 옵션이 필요한 것들이 많다. 즉, 일회성은 안된다는 것이다.
help 에 보면 이러한 옵션들에는 [P only] 또는 [P] 라는 태그가 붙어 있다.
* 참고
https://www.linode.com/community/questions/11143/top-tip-firewalld-and-ipset-country-blacklist
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-setting_and_controlling_ip_sets_using_firewalld
개별국가의 ip 목록 가져오기 - 예, 중국
# wget http://www.ipdeny.com/ipblocks/data/countries/cn.zone
모든 국가의 ip 목록을 가져오려면 아래와 같이 가져와서 압축을 풀면 된다.
# wget http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz
ㅁ ipset 만들기
# firewall-cmd --permanent --new-ipset=cnlist --type=hash:net --option=family=inet --option=hashsize=4096 --option=maxelem=200000
ㅇ 옵션
--permanent 를 반드시 사용해야만 한다. [P only]
--type 은 반드시 지정을 해 주어야 한다.
--option 은 없어도 된다.
ㅇ 지원가능한 types
# firewall-cmd --get-ipset-types
ㅁ ipset 에 ip 목록 입력하기
# firewall-cmd --permanent --ipset=cnlist --add-entries-from-file=./cn.zone
- 주의 : 여기서도 --permanent 가 반드시 필요하다.
ㅁ 입력한 ipset 확인
# firewall-cmd --permanent --get-ipsets
# firewall-cmd --permanent --info-ipset=cnlist
- 주의 : 여기서도 --permanent 가 반드시 있어야 한다. permanent 한것은 permanent 로만 확인 가능.
ㅁ ipset 을 drop zone 에 적용하기
ㅇ 기존에 있는 zone 들 확인하기
# firewall-cmd --permanent --get-zones
ㅇ drop zone 에 추가하기
# firewall-cmd --permanent --zone=drop --add-source=ipset:cnlist
ㅇ ssh service 를 차단하도록 추가
# firewall-cmd --permanent --zone=drop --add-service=ssh
ㅇ permanent 를 실제 서비스에 적용하기 위해서는 reload 가 필요하다.
# firewall-cmd --reload
시간이 좀 많이 걸린다. 몇분. ip 목록이 많을 수록 시간이 많이 걸리는 듯 하다.
ㅁ ipset 을 drop zone 에서 제거하기
ㅇ 적용되어 있는 소스 확인
# firewall-cmd --permanent --zone=drop --list-sources
ㅇ 소스 제거
# firewall-cmd --permanent --zone=drop --remove-source=ipset:cnlist
ㅁ ipset 삭제
# firewall-cmd --permanent --delete-ipset=cnlist
ㅁ P only
ipset 관련 옵션들은 --permanent 옵션이 필요한 것들이 많다. 즉, 일회성은 안된다는 것이다.
help 에 보면 이러한 옵션들에는 [P only] 또는 [P] 라는 태그가 붙어 있다.
* 참고
https://www.linode.com/community/questions/11143/top-tip-firewalld-and-ipset-country-blacklist
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-setting_and_controlling_ip_sets_using_firewalld
추천0
댓글목록
등록된 댓글이 없습니다.