[Linux,Xubuntu]UFW방화벽 사용방법 / How to use UFW firewall

👉🏻 UFW(Uncomplicated Firewall)는 데비안 및 우분투 계열 리눅스에서 방화벽을 쉽게 설정하기 위해 개발된 도구입니다.
UFW (Uncomplicated Firewall) is a tool developed to easily set up a firewall in Debian and Ubuntu-based Linux distributions.

👉🏻 방화벽 설정에 참고 하시면 됩니다.
Please refer to the firewall settings.

👉🏻 방화벽 활성화 ,비활성화
Enable,disable firewall

sudo ufw enable
sudo ufw disable

👉🏻 방화벽 설정 상태 확인
View firewall settings status

✔️ sudo ufw status

22/tcp                     ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
3000                       ALLOW       Anywhere                                   
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere   

👉🏻 방화벽 기본정책설정
Firewall basic policy settings

✔️ 기본적으로 들어오는 모든 연결은 차단하고, 나가는 연결은 허용하기
Basically, block all incoming connections and allow outgoing connections.

sudo ufw default deny incoming

sudo ufw default allow outgoing

👉🏻 IP주소기반 제어
IP address-based control

✔️ allow는 허용 deny는 차단
Allow allows, deny blocks

✔️ 특정 아이피 주소 접근 허용하기
Allow access from specific IP addresses

sudo ufw allow from 192.168.1.10

✔️ 특정 아이피가 특정 포트에 접근하는 것을 허용
Allow specific IPs to access specific ports

sudo ufw allow from 192.168.1.10 to any port

👉🏻 포트나 서비스 허용 및 차단
Allowing and blocking ports and services

✔️ http포트 허용 및 차단
Allow and block http ports

sudo ufw allow 80 # allow http

sudo ufw deny 80 # deny http

👉🏻 규칙 삭제 및 초기화
Delete and reset rules

✔️ 방화벽 설정을 번호로 보기
View firewall settings by number

sudo ufw status numbered

✔️ 방화벽 설정 삭제
Delete firewall settings

sudo ufw delete [rule number]

✔️ 포트번호로 삭제
Delete by port number

— 허용 설정된 규칙 삭제
Delete a rule that is set to allow

sudo ufw delete allow [port number]

— 차단 설정된 규칙 삭제
Delete a blocked rule

sudo ufw delete deny [port number]

👉🏻 방화벽 초기화
Reset firewall

✔️ 모든설정이 초기화 되고 방화벽이 비활성화 됨.
All settings will be reset and the firewall will be disabled.

sudo ufw reset

Leave a Reply