0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ufw 備忘

0
Last updated at Posted at 2021-08-03

有効化

sudo ufw allow proto tcp to 0.0.0.0/0 port 22
sudo ufw enable
sudo ufw status
sudo ufw reload 

実行例

$ sudo ufw allow proto tcp to 0.0.0.0/0 port 22
$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  

$ sudo ufw reload 
Firewall reloaded

設定確認

sudo ufw status

ルールの削除

sudo ufw delete <ルールの番号>

実行例

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     REJECT      Anywhere                  
10.125.0.0/16 22/tcp       ALLOW       Anywhere                  

$ sudo ufw delete 1
Deleting:
 reject 22/tcp
Proceed with operation (y|n)? y
Rule deleted
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
10.125.0.0/16 22/tcp       ALLOW       Anywhere                  

Dockerのポートフォワード

Dockerコンテナにポートフォワード設定したとき、ufwでフォワード元のポートへのアクセスを許可しなくても通信できてしまった。
Dockerのポートフォワードを設定すると、iptablesが書き換えられるのでufwでポートへのアクセス許可をしなくても通信できてしまうようである。1

Chain DOCKER (2 references)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            172.19.0.3           tcp dpt:80
  1. https://qiita.com/jqtype/items/9574ef74868b73323939

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?