티스토리 뷰
Centos7 에 iptables 대신 기본적으로 활성화 되는 방화벽 (firewalld)
참고한 원문사이트
https://www.lesstif.com/pages/viewpage.action?pageId=43844015
https://sepiros.tistory.com/7
기존 방식대로 커널에서 netfilter 가 처리하는것은 동일하다.
firewalld 위치
/usr/lib/firewalld
/etc/firewalld
/etc/firewalld/firewalld.conf : 설정파일 (global?)
/etc/firewalld/zone/*.xml : 각 zone 에 대한 설정파일?
iptables 과 유사하게 중지 및 시작이 가능하다.
service firewalld stop
service firewalld start
systemctl stop firewalld.service
systemctl start firewalld.service
iptables 를 사용해도 무관하나 차츰 firewalld 로 점점 넘어갈 예정? 이므로 사용법을 숙지해두는것이 좋다?
기본적으로 간단한 정책 추가
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload
firewall-cmd : 즉시 적용, 정책 저장하지 않음 (iptables Command)
firewall-cmd --permanent : 정책 저장 (/etc/sysconfig/iptables)
미리 정의된 zone 확인
firewall-cmd --get-zones
block dmz drop external home internal public trusted work
미리 어떤 용도에 맞게 zone 이 생성되어 있다.
미리 정의된 service (port) 확인
firewall-cmd --get-services
RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry docker-swarm dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls managesieve mdns minidlna mongodb mosh mountd ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius redis rpc-bind rsh rsyncd samba samba-client sane sip sips smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server
service 이름을 포트 번호로 매칭해주는 역활? 인듯 하다 (포트 번호를 안외어도 되는?)
모든 zone 을 자세하게 보기
firewall-cmd --list-all-zones (현재 메모리에 저장된)
firewall-cmd --permanent --list-all-zones (현재 메모리에도 저장되었으며 파일에도 저장되어 있는 영구적)
firewall-cmd --permanent --list-all --zone=존이름
block
target: %%REJECT%%
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
dmz
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
drop
target: DROP
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3
sources:
services: ssh dhcpv6-client ftp telnet smtp
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
: service (오픈된 서비스)
zone 추가
firewall-cmd --permanent --new-zone=존이름
zone 삭제
firewall-cmd --permanent --delete-zone=존이름
default zone 확인
firewall-cmd --get-default-zone
firewall-cmd 에서 zone 이 생략되면 default zone 으로 설정됨
활성화된 zone 확인
firewall-cmd --get-active-zone
public
interfaces: enp0s3
현재 활성화 된 정보
firewall-cmd --list-all {zone이름}
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3
sources:
services: ssh dhcpv6-client ftp telnet smtp
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
default zone 변경
firewall-cmd --set-default-zone=dmz
포트 추가
firewall-cmd --permanent --zone=public --add-port=포트번호/프로토콜
firewall-cmd --permanent --zone=public --add-port=80/tcp
포트 범위 (80-88)
firewall-cmd --permanent --zone=public --add-port=80-88/tcp
포트 삭제
firewall-cmd --permanent --zone=public --remove-port=80/tcp
아이피 & 포트 지정
firewall-cmd --permanent --zone=public --add-source=192.168.1.0/24 --add-port=22/tcp
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: --add-souece=192.168.10.198
rice-rule
firewall-cmd 에서 제공하지 않는 옵션인 경우 rich-rule 언어를 사용하여 복잡한 방화벽 규칙 수립 가능
문법 구조
rule
[family="rule family"]
[source]
[destination]
service|port|protocol|icmp-block|icmp-type|masquerade|forward-port|source-port
[log]
[audit]
[accept|reject|drop|mark]
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="9000" accept"
:추가
firewall-cmd --permanent --zone=public --remove-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="9000" accept"
:삭제
firewall-cmd --permanent --zone=public --query-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="9000" accept"
: 확인
direct
iptables 명령처럼 사용 가능
firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -o eth_ext -j MASQUERADE
firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -s 10.1.1.0/24 -i ens37 -m state --state NEW,ESTABLISHED -j ACCEPT
firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -s 192.168.100.1/32 -j DROP
firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d 192.168.100.1/32 -j DROP
firewall-cmd --permanent --direct --add-rule ipv4 raw PREROUTING 0 !-s 192.168.1.1 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 raw PREROUTING 0 ! -m set --match-set ALLOW_IP src --dport 80 -j DROP
# 설정한 아이피 이외에 인,아웃바운드 다 차단하기 (IPSET 과 연동)
firewall-cmd --direct --permanent --add-rule ipv4 raw OUTPUT 0 -m set ! --match-set ALLOW_IP dst -j DROP
firewall-cmd --direct --permanent --add-rule ipv4 raw OUTPUT 0 -m set ! --match-set ALLOW_IP src -j DROP
zone 에 할당된 이더넷 포트 변경
firewall-cmd --zone=dmz --change-interface=eth0
좀 어렵네?
'Linux' 카테고리의 다른 글
wordpress (0) | 2019.02.20 |
---|---|
FTP 관련 장애 및 해결방법? (0) | 2019.02.18 |
/etc/skel (0) | 2019.01.31 |
Centos7 Gnome (GUI) VirtualBox 설치 (0) | 2019.01.30 |
centos7 (GUI) GNOME 원격 터미널 접속하기 (0) | 2019.01.30 |
- Total
- Today
- Yesterday
- WAF
- Apache
- cURL
- HAProxy
- mariadb
- mod_security
- ntp
- centOS7
- ssh
- SSL
- GeoIP
- 리눅스
- yum
- softether
- php
- 인증서
- MySQL
- kvm
- OpenVPN
- 베이어다이나믹
- pptp
- iptables
- IPSEC
- gitlab
- L2TP
- galera
- centos8
- NGINX
- virtualbox
- glusterfs
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |