캠핑과 개발

CentOS 7/RHEL 7부터는 방화벽을 데몬이 firewalld로 변경되었다. 방화벽 설정을 iptables 명령어 대신 firewall-cmd(콘솔), firewall-config(X-Windows) 명령어를 사용하여 설정한다. 


설치

  1. yum install firewalld
  2. systemctl start firewalld
  3. systemctl enable firewalld


설정

설정파일

/etc/firewalld/zones/public.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <zone>
  3.   <short>Public</short>
  4.   <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accept
  5. ed.</description>
  6.   <service name="dhcpv6-client"/>
  7.   <service name="http"/>
  8.   <service name="ssh"/>
  9.   <service name="https"/>
  10. </zone>


재기동

service iptables restart 대신 아래 명령어 사용

firewall-cmd --rel


zone

사전에 정의된 zone 목록 출력

firewall-cmd --get-zones


전체 존 목록을 상세하게 출력

firewall-cmd --list-all-zones


기존 존  출력

firewall-cmd --get-default-zone


활성화된 존 출력

firewall-cmd --get-active-zone


서비스 목록

firewall-cmd --get-services


permanent로 등록된 서비스 목록

firewall-cmd --permanent --list-all


임의 포트 추가

--add-port=<portid> [-<portid>]/<protocol> 옵션을 사용하여 포트 추가

firewall-cmd --zone=public --add-port=8080/tcp


포트 삭제

--remove-port=<portid> [-<portid>]/<protocol> 옵션 사용

firewall-cmd --zone=public --remove-port=8080/tcp


rich-rule

firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4"  source address="192.168.10.0/24"  port protocol="tcp" port="9000" accept"


방화벽에 포트 추가

  1. firewall-cmd --permanent --zone=public --add-service=http
  2. firewall-cmd --permanent --zone=public --add-service=https

기본 zone은 public이므로 --zone=public 옵션은 생략 가능



출처 : https://www.lesstif.com/pages/viewpage.action?pageId=22053128#RHEL/CentOS7에서방화벽(firewalld)설정하기-설치



'DEVELOPMENT > Linux' 카테고리의 다른 글

logroate 옵션  (0) 2017.11.22
특정 계정으로 쉘 실행하기  (0) 2017.11.15
[Linux] Proxy 서버 설정하기  (0) 2015.07.22
[tip] 리눅스에서 부팅시 간단하기 시작 프로그램 등록하기  (0) 2015.05.12
crontab 설명  (0) 2015.05.06