Rocky Linux 10 / 방화벽 관리

Rocky Linux는 firewalld를 기본 방화벽으로 사용하며, firewall-cmd 명령어로 실시간 설정이 가능합니다. 포트나 서비스를 열고 닫거나, Zone을 통해 네트워크 접근을 세분화하여 관리할 수 있습니다. 설정은 일시적 또는 영구적으로 적용 가능합니다.

방화벽 상태 확인

방화벽이 실행 중이면 running, 실행 중이 아니면 not running을 출력합니다.

# firewall-cmd --state

방화벽 시작과 중지

방화벽을 시작합니다.

# systemctl start firewalld

방화벽을 중지합니다.

# systemctl stop firewalld

시스템 시작 시 방화벽이 자동으로 시작하도록 합니다.

# systemctl enable firewalld

시스템 시작 시 방화벽이 자동으로 시작하지 않도록 합니다.

# systemctl disable firewalld

열려 있는 서비스와 포트 확인

열려 있는 서비스를 출력합니다.

# firewall-cmd --list-services

열려 있는 포트를 출력합니다.

# firewall-cmd --list-ports

서비스 허용과 차단

임시 허용과 차단

http 서비스를 허용합니다.

# firewall-cmd --add-service=http

http 서비스를 차단합니다.

# firewall-cmd --remove-service=http

위와 같이 하면 바로 적용됩니다.

임시 정책이므로 firewalld 서비스를 reload, restart하거나 firewall-cmd --reload를 하면 허용 또는 차단이 해제됩니다.

영구 허용과 차단

http 서비스를 영구적으로 허용합니다.

# firewall-cmd --add-service=http --permanent

http 서비스를 영구적으로 차단합니다.

# firewall-cmd --remove-service=http --permanent

아래와 같이 명령해야 적용됩니다.

# firewall-cmd --reload

서비스 목록

서비스 목록은 --get-services 옵션으로 볼 수 있습니다.

# firewall-cmd --get-services
0-AD RH-Satellite-6 RH-Satellite-6-capsule afp alvr amanda-client amanda-k5-client amqp amqps anno-1602 anno-1800 apcupsd aseqnet audit ausweisapp2 bacula bacula-client bareos-director bareos-filedaemon bareos-storage bb bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc bittorrent-lsd ceph ceph-exporter ceph-mon cfengine checkmk-agent civilization-iv civilization-v cockpit collectd condor-collector cratedb ctdb dds dds-multicast dds-unicast dhcp dhcpv6 dhcpv6-client distcc dns dns-over-quic dns-over-tls docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server factorio finger foreman foreman-proxy freeipa-4 freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp galera ganglia-client ganglia-master git gpsd grafana gre high-availability http http3 https ident imap imaps iperf2 iperf3 ipfs ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kdeconnect kerberos kibana klogin kpasswd kprop kshell kube-api kube-apiserver kube-control-plane kube-control-plane-secure kube-controller-manager kube-controller-manager-secure kube-nodeport-services kube-scheduler kube-scheduler-secure kube-worker kubelet kubelet-readonly kubelet-worker ldap ldaps libvirt libvirt-tls lightning-network llmnr llmnr-client llmnr-tcp llmnr-udp managesieve matrix mdns memcache minecraft minidlna mndp mongodb mosh mountd mpd mqtt mqtt-tls ms-wbt mssql murmur mysql nbd nebula need-for-speed-most-wanted netbios-ns netdata-dashboard nfs nfs3 nmea-0183 nrpe ntp nut opentelemetry openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy prometheus prometheus-node-exporter proxy-dhcp ps2link ps3netsrv ptp pulseaudio puppetmaster quassel radius radsec rdp redis redis-sentinel rootd rpc-bind rquotad rsh rsyncd rtsp salt-master samba samba-client samba-dc sane settlers-history-collection sip sips slimevr slp smtp smtp-submission smtps snmp snmptls snmptls-trap snmptrap spideroak-lansync spotify-sync squid ssdp ssh statsrv steam-lan-transfer steam-streaming stellaris stronghold-crusader stun stuns submission supertuxkart svdrp svn syncthing syncthing-gui syncthing-relay synergy syscomlan syslog syslog-tls telnet tentacle terraria tftp tile38 tinc tor-socks transmission-client turn turns upnp-client vdsm vnc-server vrrp warpinator wbem-http wbem-https wireguard ws-discovery ws-discovery-client ws-discovery-host ws-discovery-tcp ws-discovery-udp wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-java-gateway zabbix-server zabbix-trapper zabbix-web-service zero-k zerotier

특정 서비스에 대한 자세한 정보는 다음과 같은 방식으로 볼 수 있습니다.

# firewall-cmd --info-service=http
http
  ports: 80/tcp
  protocols:
  source-ports:
  modules:
  destination:
  includes:
  helpers:

포트 허용과 차단

임시 허용과 차단

80 TCP 포트를 허용합니다.

# firewall-cmd --add-port=80/tcp

80 TCP 포트를 차단합니다.

# firewall-cmd --remove-port=80/tcp

위와 같이 하면 바로 적용됩니다.

임시 정책이므로 firewalld 서비스를 reload, restart하거나 firewall-cmd --reload를 하면 허용 또는 차단이 해제됩니다.

영구 허용과 차단

80 TCP 포트를 영구적으로 허용합니다.

# firewall-cmd --add-port=80/tcp --permanent

http 서비스를 영구적으로 차단합니다.

# firewall-cmd --remove-port=80/tcp --permanent

아래와 같이 명령해야 적용됩니다.

# firewall-cmd --reload

특정 IP 차단

192.168.1.178에서의 접속을 차단합니다.

# firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.1.178" drop'

차단한 것을 제거합니다.

# firewall-cmd --remove-rich-rule='rule family="ipv4" source address="192.168.1.178" drop'

영구 차단하고 싶다면 --permanent 옵션을 붙이고, 다시 로드합니다.

# firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.1.178" drop' --permanent
# firewall-cmd --reload

 

같은 카테고리의 다른 글
Rocky Linux 8 / root 계정으로 ssh 접속 가능하게 설정하는 방법

Rocky Linux 8 / root 계정으로 ssh 접속 가능하게 설정하는 방법

Rocky Linux를 설치할 때 가능하게 설정하지 않았다면, root 계정으로 ssh 접속을 할 수 없다. 보안 상 권장되는 설정이나, 테스트나 공부 목적 등으로 root 계정으로 ssh 접속하는 게 더 좋은 상황이라면, 다음과 같이 하여 접속을 허용할 수 있다. vi나 nano 같은 텍스트 에디터로 /etc/ssh/sshd_config 파일을 연다. 제일 밑에 다음 코드를 추가하고, 저장한다. PermitRootLogin yes 다음과 같이 ...

Rocky Linux 8 / SELinux 끄는 방법

Rocky Linux 8 / SELinux 끄는 방법

상태 확인 켜진 상태라면 Enforcing, 꺼진 상태라면 Permissive를 출력한다. getenforce 방법 1 다음과 같이 명령하면 SELinux가 꺼진다. 재부팅하면 다시 SELinux가 켜진다. setenforce 0 만약 다시 SELinux를 사용하고 싶다면 다음과 같이 명령한다. setenforce 1 방법 2 /etc/selinux/config에 다음과 같은 코드가 있다. SELINUX=enforcing 다음과 같이 바꾼다. SELINUX=disabled 시스템을 재부팅하면 적용된다. 방법 1과는 달리 재부팅해도 설정이 유지된다.

Rocky Linux 10 / 방화벽 관리

Rocky Linux 10 / 방화벽 관리

Rocky Linux는 firewalld를 기본 방화벽으로 사용하며, firewall-cmd 명령어로 실시간 설정이 가능합니다. 포트나 서비스를 열고 닫거나, Zone을 통해 네트워크 접근을 세분화하여 관리할 수 있습니다. 설정은 일시적 또는 영구적으로 적용 가능합니다.

Rocky Linux 9 / 설치

Rocky Linux 9 / 설치

다운로드 아래 링크에서 ISO 파일을 다운로드한다. https://rockylinux.org/download Boot, Minimal, DVD 세 가지가 있는데, 다음과 같이 설명되어 있다. Boot Used to install the operating system from another source (such as a HTTP repository of the binary files). Can also be used to enter Rescue Mode. Minimal Used to install the operating system from another source (such as a ...

Rocky Linux 8 / 고정 IP 설정하는 방법

Rocky Linux 8 / 고정 IP 설정하는 방법

보통 Rocky Linux를 설치할 때 IP를 설정하나, 여러 가지 이유로 IP 설정을 다시 해야 하는 경우가 있다. IP를 설정하는 두 가지 방법을 소개한다. TUI 네트워크 설정 파일을 수정하는 것보다는 NetworkManager Text User Interface(nmtui)를 이용하는 게 편하다. nmtui를 실행한다. Edit a connection을 선택한다. 설정하려는 네트워크 카드를 선택한다. 현재 설정이 나오는데... 적절히 설정한다. 다음과 같이 명령하여 반영한다. systemctl restart NetworkManager GUI Settings를 연다. Network에서 ...

Rocky Linux 9 / Apache / Virtulahost 만드는 방법

Rocky Linux 9 / Apache / Virtulahost 만드는 방법

하나의 서버에서 여러 사이트를 운영할 수 있다. Rocky Linux 9에서 Apache 웹서버로 구현하는 방법을 정리한다. Selinux가 활성화되어 있으면 작동하지 않고, 별도의 설정이 필요하다. 여기서는 Selinux를 끄고 진행한다. 목표 하나의 서버에서 두 개의 사이트를 운영한다. http://aaa.manualfactory.net로 접속하면 Welcome to AAA!, http://bbb.manualfactory.net으로 접속하면 Welcome to BBB!를 출력한다. DNS 설정 aaa.manualfactory.net. bbb.manualfactory.net 모두 같은 IP로 가도록 설정한다. 폴더와 파일 생성 /home/aaa ...

Rocky Linux 9 / Apache, PHP, MariaDB 설치

Rocky Linux 9 / Apache, PHP, MariaDB 설치

Rocky Linux 9에 Apache, PHP, MariaDB를 설치하는 방법을 정리합니다.

Rocky Linux 8 / 원격 데스크톱으로 연결하는 방법

Rocky Linux 8 / 원격 데스크톱으로 연결하는 방법

패키지 설치 다음과 같이 명령하여 EPEL(Extra Packages of Enterprise Linux) 저장소를 추가한다. dnf install epel-release xrdp 패키지를 설치한다. dnf install xrdp 방화벽 설정 원격 데스크톱이 사용하는 포트는 3389이다. firewall-cmd로 3389 포트를 열어준다. firewall-cmd --permanent --add-port=3389/tcp 방화벽을 다시 로드한다. firewall-cmd --reload 서비스 설정 systemctl 명령어로 xrdp 서비스를 시작한다. systemctl start xrdp 시스템 재부팅 후에도 자동으로 실행되게 하려면 다음과 같이 명령한다. systemctl enable xrdp 재부팅 위와 같이 했을 때 원격 ...

Rocky Linux 9 / hostname 변경하는 방법

Rocky Linux 9 / hostname 변경하는 방법

CLI 다음과 같이 명령하면 hostname을 출력한다. hostname 다음과 같이 명령하면 hostname을 rocky로 변경한다. hostnamectl set-hostname rocky GUI 의 Device Name에서 변경한다.

Rocky Linux 9 / SSH / 포트 변경하는 방법

Rocky Linux 9 / SSH / 포트 변경하는 방법

SSH는 22 포트를 사용한다. 알려진 포트이므로 다른 포트로 변경하는 것이 보안상 좋다. Rocky Linux 9에서 SSH 포트 변경하는 방법은 다음과 같다. 포트를 1980으로 바꾼다고 가정한다. /etc/ssh/sshd_config에서 다음의 코드를... #Port 22 다음으로 변경한다. Port 1980 SELINUX가 활성화되어 있다면 다음과 같이 명령하여 1980 포트를 사용할 수 있게 만든다. semanage port -a -t ssh_port_t -p tcp 1980 만약 다음과 같은 ...