firewalld 사용하여 port forwarding 설정하기 with CentOS7
1. firewalld 설치
# yum install -y firewalld
2. 사용중인 서비스 port 오픈 미리 허용 설정
1)TCP 특정 포트 허용 (예 1~65535 전부 허용)
# firewall-cmd --permanent --zone=public --add-port=1-65535/tcp
2) UDP 특정 포트 허용(예 3000번)
# firewall-cmd --permanent --add-port=3000/udp
3. redirect 80 to 443 설정하기 (http to httpd)
1) 동일 서버내에서 redirect 하는 경우
# firewall-cmd --add-forward-port=port=80:proto=tcp:toport=443
# firewall-cmd --runtime-to-permanent
2) A서버의 80포트를 B서버의 443포트로 redirect 하는 경우, Enable masquerade 추가
# firewall-cmd --add-forward-port=port=80:proto=tcp:toport=443:toaddr=SERVER_B_IP_ADDRESS
# firewall-cmd --add-masquerade
4. 설정 확인하기
# firewall-cmd --list-all
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports: port=80:proto=tcp:toport=443:toaddr=
source-ports:
icmp-blocks:
rich rules:
#
5. 실행 명령
# systemctl enable firewalld // 기능 활성화
# systemctl disable firewalld // 기능 비활성화
# systemctl start firewalld // 시작
# systemctl stop firewalld // 중지
# systemctl restart firewalld // 재시작
'블라베 IT world > Linux Document' 카테고리의 다른 글
리눅스 shutdown 과 init 명령 활용하기 (0) | 2022.10.23 |
---|---|
(취향LinuxDoc) 한대의 서버에 복수개 IP주소 설정하기 (0) | 2022.09.11 |
firewalld 사용하여 port forwarding 설정하기 with CentOS7 (0) | 2022.08.01 |
linux/centos6, centos 7 한국시간 설정하기 (0) | 2022.05.19 |
(취향linux doc) NAS를 linux에 nfs mount 하기 (추가 nfs version 3 설정) (0) | 2022.04.12 |