{"id":947,"date":"2021-04-23T21:04:04","date_gmt":"2021-04-23T12:04:04","guid":{"rendered":"https:\/\/sirius10.net\/blog\/wordpress\/?p=947"},"modified":"2021-04-23T21:04:06","modified_gmt":"2021-04-23T12:04:06","slug":"post-947","status":"publish","type":"post","link":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/04\/23\/947\/","title":{"rendered":"\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb(ufw)"},"content":{"rendered":"\n<p>\u3000<a href=\"https:\/\/raspida.com\/firewall4raspbian-ufw\">https:\/\/raspida.com\/firewall4raspbian-ufw<\/a> \u3092\u53c2\u8003\u306b\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3082\u3063\u3068\u3082\u3001\u30eb\u30fc\u30bf\u3067\u5916\u90e8\u304b\u3089\u306e\u63a5\u7d9a\u30dd\u30fc\u30c8\u3092\u5236\u9650\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3042\u307e\u308a\u5909\u308f\u308a\u307e\u305b\u3093\u3002\u9006\u306b\u3001\u5916\u90e8\u306b\u30b5\u30fc\u30d3\u30b9\u3059\u308b\u969b\u306f\u3001\u30eb\u30fc\u30bf\u306e\u30dd\u30fc\u30c8\u958b\u653e\u3068\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u306e\u958b\u653e\u3068\u4e21\u65b9\u3084\u3089\u306a\u3051\u308c\u3070\u306a\u3089\u305a\u3001\u624b\u9593\u304c\u304b\u304b\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u5805\u7262\u306a\u30eb\u30fc\u30bf\u3067\u3042\u308c\u3070\u5fc3\u914d\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u6c11\u751f\u7528\u306e\u30eb\u30fc\u30bf\u3092\u305d\u3053\u307e\u3067\u4fe1\u7528\u3057\u3066\u3082\u3044\u3044\u306e\u304b\u3069\u3046\u304b\u7591\u554f\u3067\u3059\u3002\u7279\u306b\u53e4\u3044\u30eb\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u5c1a\u66f4\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<p class=\"console\">$ sudo apt-get install -y ufw<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8a2d\u5b9a<\/h2>\n\n\n\n<p>\u3000\u30b3\u30de\u30f3\u30c9\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u307e\u305a\u3001\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u306f\u52d5\u3044\u3066\u3044\u306a\u3044\u72b6\u614b\u3067\u8a2d\u5b9a\u3057\u307e\u3059\u306e\u3067\u3001\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"console\">$ sudo ufw status<br>Status: inactive<\/p>\n\n\n\n<p>\u3000inactive \u3067\u3042\u308c\u3070\u3001\u52d5\u3044\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5168\u62d2\u5426<\/h3>\n\n\n\n<p>\u3000\u306f\u3058\u3081\u306b\u5168\u3066\u306e\u30dd\u30fc\u30c8\u3092\u62d2\u5426\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"console\">$ sudo ufw default deny<br>Default incoming policy changed to &#8216;deny&#8217;<br>(be sure to update your rules accordingly)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5fc5\u8981\u306a\u30dd\u30fc\u30c8\u306e\u307f\u8a31\u53ef\u3057\u3066\u3044\u304f<\/h3>\n\n\n\n<p>\u3000\u6b21\u306b\u5fc5\u8981\u306a\u30dd\u30fc\u30c8\u3060\u3051\u3001\u8a31\u53ef\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u5916\u90e8\u304b\u3089\u63a5\u7d9a\u304c\u5fc5\u8981\u306a\u30dd\u30fc\u30c8\u3092\u5217\u6319\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><span style=\"font-size: 17px\" class=\"font-size\">22: ssh<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">80, 443: Apache(http, https)<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">53: dns<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">3306: MariaDB<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">11334: Rspmd<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">25,465,587,993, 995 : postfix(smtp, smtps, imaps, pop3s)<\/span><\/li><li><span style=\"font-size: 17px\" class=\"font-size\">123: ntp<\/span><\/li><\/ul>\n\n\n\n<p>\u3000\u3082\u3057\u3001\u3053\u306e\u4e2d\u3067\u3001localhost \u306e\u307f\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u3059\u308b\u3082\u306e\u306f\u8a31\u53ef\u3057\u306a\u304f\u3066\u3082\u3044\u3044\u3067\u3059\u3002localhost \u4ee5\u5916\u3078\u30b5\u30fc\u30d3\u30b9\u3059\u308b\u30dd\u30fc\u30c8\u306b\u3064\u3044\u3066\u8a31\u53ef\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"console\">$ sudo ufw allow 22<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 25<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 53<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 80<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 123<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 443<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 465<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 587<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 993<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 995<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 3306<br>Rules updated<br>Rules updated (v6)<br>$ sudo ufw allow 11334<br>Rules updated<br>Rules updated (v6)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d5\u30a3\u3084\u30fc\u30a6\u30a9\u30fc\u30eb\u306e\u8d77\u52d5<\/h2>\n\n\n\n<p class=\"console\">$ sudo ufw enable<br>Command may disrupt existing ssh connections. Proceed with operation (y|n)? y<br>Firewall is active and enabled on system startup<\/p>\n\n\n\n<p>\u3000\u78ba\u8a8d\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u307e\u3059\u3002y \u3067\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u78ba\u8a8d<\/h2>\n\n\n\n<p class=\"console\"><code>$ sudo ufw status numbered\nStatus: active\n\n     To                         Action      From\n     --                         ------      ----\n[ 1] 22                         ALLOW IN    Anywhere          \n[ 2] 25                         ALLOW IN    Anywhere                  \n[ 3] 53                         ALLOW IN    Anywhere          \n[ 4] 80                         ALLOW IN    Anywhere                  \n[ 5] 123                        ALLOW IN    Anywhere                  \n[ 6] 443                        ALLOW IN    Anywhere                  \n[ 7] 465                        ALLOW IN    Anywhere                  \n[ 8] 587                        ALLOW IN    Anywhere                  \n[ 9] 993                        ALLOW IN    Anywhere                  \n[10] 995                        ALLOW IN    Anywhere                  \n[11] 3306                       ALLOW IN    Anywhere                  \n[12] 11334                      ALLOW IN    Anywhere                  \n[13] 22 (v6)                    ALLOW IN    Anywhere (v6)             \n[14] 25 (v6)                    ALLOW IN    Anywhere (v6)             \n[15] 53 (v6)                    ALLOW IN    Anywhere (v6)             \n[16] 80 (v6)                    ALLOW IN    Anywhere (v6)             \n[17] 123 (v6)                   ALLOW IN    Anywhere (v6)             \n[18] 443 (v6)                   ALLOW IN    Anywhere (v6)             \n[19] 465 (v6)                   ALLOW IN    Anywhere (v6)             \n[20] 587 (v6)                   ALLOW IN    Anywhere (v6)             \n[21] 993 (v6)                   ALLOW IN    Anywhere (v6)             \n[22] 995 (v6)                   ALLOW IN    Anywhere (v6)             \n[23] 3306 (v6)                  ALLOW IN    Anywhere (v6)             \n[24] 11334 (v6)                 ALLOW IN    Anywhere (v6)<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u305d\u306e\u4ed6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30eb\u30fc\u30eb\u306e\u524a\u9664<\/h3>\n\n\n\n<p class=\"console\">$ sudo ufw delete \u30eb\u30fc\u30eb\u756a\u53f7<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u3092\u505c\u6b62\u3059\u308b<\/h3>\n\n\n\n<p class=\"console\">$ sudo ufw disable<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u6307\u5b9a\u3057\u3066\u8a31\u53ef\u3059\u308b<\/h3>\n\n\n\n<p>\u3000\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u3060\u3051\u8a31\u53ef\u3057\u3066\u305d\u308c\u4ee5\u5916\u306e\u5916\u90e8\u304b\u3089\u306f\u63a5\u7d9a\u3055\u305b\u306a\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"console\">$ sudo ufw allow from 192.168.0.0\/24 to any port \u30dd\u30fc\u30c8\u756a\u53f7<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000https:\/\/raspida.com\/firewall4raspbian-ufw \u3092\u53c2\u8003\u306b\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002 \u3000\u3082\u3063\u3068\u3082\u3001\u30eb\u30fc\u30bf\u3067\u5916\u90e8\u304b\u3089\u306e\u63a5\u7d9a\u30dd\u30fc\u30c8\u3092\u5236\u9650\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3042\u307e\u308a\u5909\u308f\u308a\u307e\u305b\u3093\u3002\u9006\u306b\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-947","post","type-post","status-publish","format-standard","hentry","category-server-config"],"_links":{"self":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=947"}],"version-history":[{"count":7,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/947\/revisions"}],"predecessor-version":[{"id":1082,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/947\/revisions\/1082"}],"wp:attachment":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}