{"id":116,"date":"2013-10-03T22:08:30","date_gmt":"2013-10-03T13:08:30","guid":{"rendered":"http:\/\/bam-system.ddo.jp\/wordpress\/ura\/?p=116"},"modified":"2013-10-03T22:08:30","modified_gmt":"2013-10-03T13:08:30","slug":"debian-%e6%94%bb%e6%92%83%e3%81%8b%e3%82%89%e3%81%ae%e5%ae%88%e3%82%8a%e3%82%92%e5%9b%ba%e3%82%81%e3%82%8b","status":"publish","type":"post","link":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/2013\/10\/03\/debian-%e6%94%bb%e6%92%83%e3%81%8b%e3%82%89%e3%81%ae%e5%ae%88%e3%82%8a%e3%82%92%e5%9b%ba%e3%82%81%e3%82%8b\/","title":{"rendered":"Debian \u653b\u6483\u304b\u3089\u306e\u5b88\u308a\u3092\u56fa\u3081\u308b"},"content":{"rendered":"<p>\u6b21\u306b\u3001iptables\u306b\u3088\u308b\u4f59\u8a08\u306a\u30a2\u30af\u30bb\u30b9\u306e\u906e\u65ad\u3068sshguard\u306b\u3088\u308bssh\u3078\u306e\u30d6\u30eb\u30fc\u30c8\u30d5\u30a9\u30fc\u30b9\u30a2\u30bf\u30c3\u30af\u306e\u906e\u65ad\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>Wheezy\u3067\u306fiptables\u306e\u8a2d\u5b9a\u306fiptables-persistent\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u3088\u3063\u3066\u8d77\u52d5\u6642\u306b\u518d\u8a2d\u5b9a\u3055\u308c\u308b\u304c\u3001\u3053\u306e\u6642\u70b9\u3067\u306f\u307e\u3060\u8a2d\u5b9a\u3057\u306a\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3002\u3068\u308a\u3042\u3048\u305a\u3001\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u3068SSH\u30b5\u30fc\u30d0\u30fc\u3068SMTP\u30b5\u30fc\u30d0\u30fc\u3060\u3051\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u3092\u958b\u3051\u3066\u304a\u304f\u3002<\/p>\n<p>iptables.rule<\/p>\n<p>&#8212;<\/p>\n<p>*filter<\/p>\n<p># Allows all loopback (lo0) traffic and drop all traffic to 127\/8 that doesn&#8217;t use lo0<br \/>\n-A INPUT -i lo -j ACCEPT<br \/>\n-A INPUT ! -i lo -d 127.0.0.0\/8 -j REJECT<\/p>\n<p># Accepts all established inbound connections<br \/>\n-A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<\/p>\n<p># Allows all outbound traffic<br \/>\n# You could modify this to only allow certain traffic<br \/>\n-A OUTPUT -j ACCEPT<\/p>\n<p># Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)<br \/>\n-A INPUT -p tcp &#8211;dport 80 -j ACCEPT<br \/>\n-A INPUT -p tcp &#8211;dport 443 -j ACCEPT<\/p>\n<p># Allows SSH connections<br \/>\n# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE<br \/>\n-A INPUT -p tcp -m state &#8211;state NEW &#8211;dport 22 -j ACCEPT<\/p>\n<p># Allows SMTP connections<br \/>\n-A INPUT -p tcp &#8211;dport 25 -j ACCEPT<\/p>\n<p># Allow ping<br \/>\n-A INPUT -p icmp &#8211;icmp-type 8 -j ACCEPT<\/p>\n<p># Reject all other inbound &#8211; default deny unless explicitly allowed policy:<br \/>\n-A INPUT -j REJECT<br \/>\n-A FORWARD -j REJECT<\/p>\n<p>COMMIT<\/p>\n<p>&#8212;<\/p>\n<p>\u305b\u3063\u304b\u304f\u306a\u306e\u3067IPv6\u3067\u3082\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u305f\u3044\u306e\u3067IPv6\u7528\u306b\u306f\u5225\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<p>ip6tables.rule<\/p>\n<p>&#8212;<\/p>\n<p>*filter<\/p>\n<p># Allows all loopback (lo0) traffic and drop all traffic to 127\/8 that doesn&#8217;t use lo0<br \/>\n-A INPUT -i lo -j ACCEPT<br \/>\n-A INPUT ! -i lo -d ::1\/128 -j REJECT<\/p>\n<p># Accepts all established inbound connections<br \/>\n-A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<\/p>\n<p># Allows all outbound traffic<br \/>\n# You could modify this to only allow certain traffic<br \/>\n-A OUTPUT -j ACCEPT<\/p>\n<p># Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)<br \/>\n-A INPUT -p tcp &#8211;dport 80 -j ACCEPT<br \/>\n-A INPUT -p tcp &#8211;dport 443 -j ACCEPT<\/p>\n<p># Allows SSH connections<br \/>\n# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE<br \/>\n-A INPUT -p tcp -m state &#8211;state NEW &#8211;dport 22 -j ACCEPT<\/p>\n<p># Allows SMTP connections<br \/>\n-A INPUT -p tcp &#8211;dport 25 -j ACCEPT<\/p>\n<p># Allow ping<br \/>\n-A INPUT -p ipv6-icmp &#8211;icmpv6-type 128 -j ACCEPT<\/p>\n<p># Reject all other inbound &#8211; default deny unless explicitly allowed policy:<br \/>\n-A INPUT -j REJECT<br \/>\n-A FORWARD -j REJECT<\/p>\n<p>COMMIT<\/p>\n<p>&#8212;<\/p>\n<p>\u305d\u3057\u305f\u3089\u3001\u3053\u308c\u3089\u306e\u30eb\u30fc\u30eb\u3092iptables\u306b\u98df\u308f\u305b\u308b\u3002<\/p>\n<p>iptables-restore &lt; iptables.rule<\/p>\n<p>ip6tables-restore &lt; ip6tables.rule<\/p>\n<p>\u30eb\u30fc\u30eb\u3092\u98df\u308f\u305b\u3066\u304b\u3089\u304a\u3082\u3080\u308d\u306biptables-persistent\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n<p>apt-get install iptables-persistent<\/p>\n<p>\u3059\u308b\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6642\u306b\u305d\u306e\u6642\u70b9\u3067\u306eiptables\u306e\u8a2d\u5b9a\u5185\u5bb9\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u51fa\u3059\u304b\uff1f\u3068\u5c0b\u306d\u3089\u308c\u308b\u306e\u3067yes\u3068\u7b54\u3048\u308b\u3068IPv4\u7528\u306e\u30eb\u30fc\u30eb\u3068IPv6\u7528\u306e\u30eb\u30fc\u30eb\u304c\u305d\u308c\u305e\u308c\/etc\/iptables\/rules.v4,rules.v6\u306b\u66f8\u304d\u51fa\u3055\u308c\u308b\u3002\u3053\u308c\u3067\u3001\u518d\u8d77\u52d5\u3057\u305f\u3089\u30eb\u30fc\u30eb\u304c\u5fa9\u6d3b\u3059\u308b\u3002<\/p>\n<p>\u6b21\u306bapt-get install sshguard\u3067sshguard\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002\u3053\u308c\u306f\u8d77\u52d5\u3059\u308b\u3068\u81ea\u52d5\u7684\u306bsshguard\u7528\u306eiptables\u30eb\u30fc\u30eb\u3092iptables\u306b\u8ffd\u52a0\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u7279\u306b\u306a\u306b\u304b\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u3002<\/p>\n<p>\u3053\u308c\u3067\u518d\u8d77\u52d5\u3059\u308c\u3070\u4f59\u8a08\u306a\u30dd\u30fc\u30c8\u306e\u906e\u65ad\u3068\u30d6\u30eb\u30fc\u30c8\u30d5\u30a9\u30fc\u30b9\u653b\u6483\u306e\u906e\u65ad\u304c\u59cb\u307e\u308b\u3002<\/p>\n<p>\u3082\u3057iptables\u306e\u8a2d\u5b9a\u306b\u5931\u6557\u3057\u305f\u6642\u306f\u3001sysv-rc-conf\u3067iptables-persistent\u3068sshguard\u3092\u7121\u52b9\u306b\u3057\u305f\u4e0a\u3067\u518d\u8d77\u52d5\u3057\u3001\u518d\u3073iptables\u306b\u65b0\u3057\u3044\u30eb\u30fc\u30eb\u3092\u98df\u308f\u305b\u305f\u5f8c\u3001dpkg-reconfigure iptables-persistent\u3067\u518d\u3073\u30eb\u30fc\u30eb\u3092\u66f8\u304d\u51fa\u3057\u3001\u305d\u306e\u5f8c\u3001sysv-rc-conf\u3067iptables-persistent\u3068sshguard\u3092\u518d\u5ea6\u6709\u52b9\u5316\u3057\u3066\u518d\u8d77\u52d5\u3059\u308c\u3070\u3088\u3044\u3002<\/p>\n<p>\u6ce8\u610f\u3059\u3079\u304d\u306f\u3001sshgurad\u304c\u7acb\u3061\u4e0a\u304c\u3063\u305f\u72b6\u614b\u3067dpkg-reconfigure iptables-persistent\u3092\u3059\u308b\u3068sshguard\u7528\u306eiptables\u30eb\u30fc\u30eb\u304c\u542b\u307e\u308c\u305f\u72b6\u614b\u3067\u30eb\u30fc\u30eb\u3092\u66f8\u304d\u51fa\u3057\u3066\u3057\u307e\u3044\u3001\u7d50\u679c\u3001\u6b21\u306b\u8d77\u52d5\u3057\u305f\u3068\u304d\u306biptables-persistent\u3068sshguard\u304c\u3069\u3061\u3089\u3082sshguard\u7528\u306e\u30eb\u30fc\u30eb\u3092\u767b\u9332\u3057\u3066\u4e8c\u91cd\u306b\u767b\u9332\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u3002\u305d\u306e\u5834\u5408\u306f\u3001\/etc\/iptables\/rules.v4,v6\u3092\u76f4\u63a5\u66f8\u304d\u63db\u3048\u3066sshguard\u7528\u306e\u884c\u3092\u524a\u3063\u3066\u3082\u3044\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6b21\u306b\u3001iptables\u306b\u3088\u308b\u4f59\u8a08\u306a\u30a2\u30af\u30bb\u30b9\u306e\u906e\u65ad\u3068sshguard\u306b\u3088\u308bssh\u3078\u306e\u30d6\u30eb\u30fc\u30c8\u30d5\u30a9\u30fc\u30b9\u30a2\u30bf\u30c3\u30af\u306e\u906e\u65ad\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3002 Wheezy\u3067\u306fiptables\u306e\u8a2d\u5b9a\u306fiptables-persistent\u30d1\u30c3\u30b1\u30fc\u30b8\u306b &hellip; <a href=\"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/2013\/10\/03\/debian-%e6%94%bb%e6%92%83%e3%81%8b%e3%82%89%e3%81%ae%e5%ae%88%e3%82%8a%e3%82%92%e5%9b%ba%e3%82%81%e3%82%8b\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Debian \u653b\u6483\u304b\u3089\u306e\u5b88\u308a\u3092\u56fa\u3081\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-2","ja"],"_links":{"self":[{"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":0,"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"wp:attachment":[{"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bam-system.ddo.jp\/wordpress\/ura\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}