·터미널 명령어

ufw

네트워크

쓰는 꼴

sudo ufw <allow|deny|status> ...

Debian·Ubuntu에서 iptables를 쉬운 낱말로 감싼 방화벽입니다 — `enable` 전에 SSH를 먼저 열어야 지금 붙어 있는 연결이 끊기지 않고, Docker는 포트를 iptables에 직접 꽂기 때문에 ufw 규칙이 그 포트를 막지 못합니다.

자주 쓰는 옵션

옵션
allow 22/tcpOpen a port; allow OpenSSH uses the named application profile instead.
allow from 10.0.0.0/8 to any port 5432Open a port to one network only.
deny <port>Block it explicitly.
default deny incomingThe usual starting point, set before you enable.
status numberedList the rules with the numbers that delete needs.
delete <n>Remove rule number n.
enable / disableTurn the firewall on or off, persistently.

예시

sudo ufw allow OpenSSH && sudo ufw enable

Allow SSH first, then switch the firewall on.

sudo ufw status numbered

See what is open and get the rule numbers.

sudo ufw delete 3

Remove the third rule.

연결이 안 될 때 어디까지 갔는지 좁혀 갑니다 — 이름이 안 풀리는지, 길이 없는지, 포트가 막혔는지.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. ufw은 무엇을 하나요?

Debian·Ubuntu에서 iptables를 쉬운 낱말로 감싼 방화벽입니다 — `enable` 전에 SSH를 먼저 열어야 지금 붙어 있는 연결이 끊기지 않고, Docker는 포트를 iptables에 직접 꽂기 때문에 ufw 규칙이 그 포트를 막지 못합니다.

Q. 어떻게 치나요?

sudo ufw <allow|deny|status> ... — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 7개입니다. 전체 목록은 man ufw에 있습니다. 이 명령은 네트워크 갈래입니다.

같이 보는 명령

man 페이지: man ufw