firewalld firewall-cmd ipset 으로 국가 ip 차단하기 > 개발

본문 바로가기
사이트 내 전체검색

개발

firewalld firewall-cmd ipset 으로 국가 ip 차단하기

페이지 정보

profile_image
작성자 관리자 (61.♡.26.87)
댓글 0건 조회 3,380회 작성일 20-06-29 16:45

본문

ㅁ 국가별 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

추천0

댓글목록

등록된 댓글이 없습니다.

Total 386건 6 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
2861902002-27
2851627002-26
2841856002-26
2832312002-25
2822272002-17
2812219002-17
2802308001-14
2792004011-07
2781751010-07
2772033010-07
2762401010-06
2752313010-06
2742153009-27
2732563009-07
2721847009-06
2712187006-30
2702522006-30
2692789006-29
열람중3381006-29
2671986006-22

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.