RHEL/CentOS 7 방화벽(firewalld) 설정
콘솔 : firewall-cmd
x-windows : firewall-config
1.설치
yum -y install firewalld
2. 서비스 시작 및 활성화
systemctl start firewalld
systemctl enable firewalld
3. 서비스 종료
systemctl stop firewalld
4. firewalld 재시작
firewall-cmd --reload
5.방화벽에 포트추가
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=8080/tcp
※ firewalld 재시작해야 반영됨
6.방화벽에 포트삭제
firewall-cmd --permanent --zone=public --remove-port=8080/tcp
6.방화벽에 포트 list 확인
firewall-cmd --list-ports
7. 설정확인
firewall-cmd --list-services
[root@WAS live]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens192
sources:
services: dhcpv6-client ssh
ports: 5050/tcp 80/tcp 8080/tcp 8443/tcp
protocols:
masquerade: no
forward-ports: port=80:proto=tcp:toport=8080:toaddr=
port=443:proto=tcp:toport=8443:toaddr=
source-ports:
icmp-blocks:
rich rules:
[root@WAS live]#
-------------------------------------------------------------------------------------------------------------------------
CentOS port open
웹서비스를 위한 포트 열기(port open)
[root@rfid bin]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@rfid bin]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@rfid bin]#
[root@dnsTEST ~]#
[root@dnsTEST ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@dnsTEST ~]#
[root@rfid bin]#
---방화벽 오픈 목록 확인하기
[root@rfid bin]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:webcache
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@rfid bin]#
--방화벽 중지 하기
[root@dnsTEST ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@dnsTEST ~]# service iptables status
iptables: Firewall is not running.
[root@dnsTEST ~]#
[root@dnsTEST ~]#
텍스트모드로 각종 설정하기
네트워크설정, 방화벽 설정등
[root@dnsTEST ~]#
[root@dnsTEST ~]# setup
[root@dnsTEST ~]#
[root@dnsTEST ~]#
Text Mode Setup Utility 1.19.9 (c) 1999-2006 Red Hat, Inc.
┌────────┤ Choose a Tool ├─────────┐
│ │
│ Authentication configuration │
│ Firewall configuration │
│ Keyboard configuration │
│ Network configuration │
│ System services │
│ │
│ ┌──────────┐ ┌──────┐ │
│ │ Run Tool │ │ Quit │ │
│ └──────────┘ └──────┘ │
│ │
│ │
└──────────────────────────────────┘
<Tab>/<Alt-Tab> between elements | Use <Enter> to edit a selection
'OS > Linux' 카테고리의 다른 글
linux_runlevel변경 (0) | 2020.04.27 |
---|---|
Download Oracle Java JRE & JDK using a script (0) | 2020.04.27 |
Install PostgreSQL on CentOS 6.3 [ 설치 , 백업 , 복구 ] (0) | 2020.04.27 |
Starting Tomcat as a Service on Linux (리눅스 부팅시 Tomcat 시작하기 ) (0) | 2020.04.27 |
Install Webmin on CentOS 6 (0) | 2020.04.27 |