{"id":417,"date":"2021-11-19T00:09:08","date_gmt":"2021-11-18T15:09:08","guid":{"rendered":"https:\/\/blog.nishinari.or.jp\/?p=417"},"modified":"2021-12-15T00:21:18","modified_gmt":"2021-12-14T15:21:18","slug":"%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e5%86%8d%e6%a7%8b%e7%af%89%e8%a6%9a%e6%9b%b8%ef%bc%88004%ef%bc%89%e3%83%bc%e3%82%a4%e3%83%b3%e3%83%95%e3%83%a9%e6%95%b4%e5%82%99%ef%bc%8801%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.nishinari.or.jp\/?p=417","title":{"rendered":"\u30b5\u30fc\u30d0\u30fc\u518d\u69cb\u7bc9\u899a\u66f8\uff08004\uff09\u30fc\u30a4\u30f3\u30d5\u30e9\u6574\u5099\uff0801\uff09"},"content":{"rendered":"<p>\u25ce\u9060\u9694\u64cd\u4f5c\u3092\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u3001SSH \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n<a href=\"https:\/\/www.server-world.info\/query?os=Ubuntu_20.04&amp;p=ssh&amp;f=1\">\u30b5\u30fc\u30d0\u30fc\u30ef\u30fc\u30eb\u30c9<\/a>\u306e\u8a2d\u5b9a<br \/>\n<code><br \/>\nroot@Voyager:~# apt -y install openssh-server<br \/>\n<\/code><br \/>\n\u30af\u30e9\u30a4\u30a8\u30f3\u30c8\u5074\u3067\u306f\u3001Windows \u3084 Mac \u3067\u3082\u3001Terminal \u7cfb\u7d71\u306e\u30a2\u30d7\u30ea\uff08Wiindows \u3067\u306f\u3001<a href=\"https:\/\/ja.osdn.net\/projects\/ttssh2\/\">Teraterm<\/a> \u306a\u3069\u3001\u6700\u8fd1\u306eWindows \u3067\u306f\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u3001ssh -l \u30e6\u30fc\u30b6\u30fc\u540d \u30b5\u30fc\u30d0\u30fc\u306eIP\u756a\u53f7 \u3067\u30ed\u30b0\u30a4\u30f3\u53ef\u80fd\uff09\u4e0b\u56f3\u306f\u3001Teraterm \u306e\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u3002<\/p>\n<div id='gallery-1' class='gallery galleryid-417 gallery-columns-1 gallery-size-medium'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blog.nishinari.or.jp\/wp-content\/uploads\/2021\/11\/1034.png'><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"222\" src=\"https:\/\/blog.nishinari.or.jp\/wp-content\/uploads\/2021\/11\/1034-300x222.png\" class=\"attachment-medium size-medium\" alt=\"\" srcset=\"https:\/\/blog.nishinari.or.jp\/wp-content\/uploads\/2021\/11\/1034-300x222.png 300w, https:\/\/blog.nishinari.or.jp\/wp-content\/uploads\/2021\/11\/1034.png 538w\" sizes=\"auto, 100vw\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n\n<p>\u25ce\u540c\u4e00LAN\u5185\u3067\u306e\u6642\u523b\u8a2d\u5b9a<br \/>\n<a href=\"https:\/\/www.server-world.info\/query?os=Ubuntu_20.04&amp;p=ntp&amp;f=1\">\u30b5\u30fc\u30d0\u30fc\u30ef\u30fc\u30eb\u30c9<\/a>\u306b\u5f93\u3044\u3001<br \/>\n<code><br \/>\nroot@voyager:~# apt -y install ntp<br \/>\nroot@voyager:~# jed \/etc\/ntp.conf<br \/>\n<\/code><br \/>\n\u3053\u308c\u3067\u3001LAN\u5185\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8PC\u3068\u306e\u6642\u523b\u540c\u671f\u304c\u53ef\u80fd\u3002<\/p>\n<p>\u25ceLAN \u3068\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306e\u63a5\u7d9a\uff08\u30d5\u30a1\u30a4\u30a2\u30fc\u30a6\u30a9\u30fc\u30eb\uff09<br \/>\n\u3084\u3084\u53e4\u5178\u7684\u306a\u3001iptables \u3092\u4f7f\u7528<br \/>\n<code><br \/>\nroot@voyager:~# apt -y install iptables<br \/>\n<\/code><br \/>\n<code><br \/>\n# Generated by iptables-save v1.8.4 on Thu Sep 30 17:59:40 2021<br \/>\n*nat<br \/>\n#xxxxx - Variable<br \/>\n<code><br \/>\n:PREROUTING ACCEPT [xxxxxx:xxxxxx]<br \/>\n:INPUT ACCEPT [xxxxxx:xxxxxx]<br \/>\n:OUTPUT ACCEPT [xxxxxx:xxxxxx]<br \/>\n:POSTROUTING ACCEPT [xxxxxx:xxxxxx]<br \/>\n<strong>#Very Important<br \/>\n#\u25cb\u25cb\u25cb1- LAN Card name<br \/>\n-A POSTROUTING -s 192.168.0.0\/24 -o \u25cb\u25cb\u25cb1 -j MASQUERADE<br \/>\n#End<\/strong><br \/>\nCOMMIT<br \/>\n# Completed on Thu Sep 30 17:59:40 2021<br \/>\n# Generated by iptables-save v1.8.4 on Thu Sep 30 17:59:40 2021<br \/>\n*filter<br \/>\n#xxxxx - Variable<br \/>\n:INPUT ACCEPT [xxxxxx:xxxxxx]<br \/>\n:FORWARD ACCEPT [xxxxxx:xxxxxx]<br \/>\n:OUTPUT ACCEPT [xxxxxx:xxxxxx]<br \/>\n# \u60aa\u8cea\u306a\u30d1\u30b1\u30c3\u30c8\u3092\u6392\u9664\u30fc\u304a\u307e\u3058\u306a\u3044\u306e\u3088\u3046\u306a\u3082\u306e<br \/>\n-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP<br \/>\n-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP<br \/>\n-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP<br \/>\n# \u4ee5\u4e0b\u306ePort \u3092\u8a31\u53ef<br \/>\n-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 465 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 995 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT<br \/>\n-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT<br \/>\n-A INPUT -p icmp -j ACCEPT<br \/>\n-A INPUT -i lo -j ACCEPT<br \/>\n-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT<br \/>\n-A INPUT -j LOG --log-prefix \"drop_packet:\"<br \/>\nCOMMIT<br \/>\n# Completed on Thu Sep 30 17:59:40 2021<br \/>\n<\/code><br \/>\n\u3053\u308c\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u66f8\u304f\u3068\u2026<br \/>\n<code><br \/>\nroot@voyager:~# cat iptables.sh<\/code><\/code><\/p>\n<p>#!\/bin\/sh<\/p>\n<p># \u8a2d\u5b9a\u3092\u30af\u30ea\u30a2<br \/>\niptables -F<\/p>\n<p># \u57fa\u672c\u65b9\u91dd[1]<br \/>\n# \u30b5\u30fc\u30d0\u30fc\u304c\u53d7\u4fe1\u3059\u308b\u30d1\u30b1\u30c3\u30c8\u3092\u8a31\u53ef<br \/>\niptables -P INPUT ACCEPT<br \/>\n# \u30b5\u30fc\u30d0\u30fc\u304c\u7d4c\u7531\u3055\u305b\u308b\u30d1\u30b1\u30c3\u30c8\u3092\u8a31\u53ef<br \/>\niptables -P FORWARD ACCEPT<br \/>\n#iptables -P FORWARD DROP<br \/>\n# \u30b5\u30fc\u30d0\u30fc\u304c\u9001\u4fe1\u3059\u308b\u30d1\u30b1\u30c3\u30c8\u3092\u8a31\u53ef<br \/>\niptables -P OUTPUT ACCEPT<\/p>\n<p># \u30b5\u30fc\u30d0\u653b\u6483\u5bfe\u7b56\u95a2\u9023<br \/>\n# \u30c7\u30fc\u30bf\u3092\u6301\u305f\u306a\u3044\u30d1\u30b1\u30c3\u30c8\u306e\u63a5\u7d9a\u3092\u7834\u68c4<br \/>\niptables -A INPUT -p tcp &#8211;tcp-flags ALL NONE -j DROP<br \/>\n# SYNflood\u653b\u6483\u3068\u8ffd\u308f\u308c\u308b\u63a5\u7d9a\u3092\u7834\u68c4<br \/>\niptables -A INPUT -p tcp ! &#8211;syn -m state &#8211;state NEW -j DROP<br \/>\n# \u30b9\u30c6\u30eb\u30b9\u30b9\u30ad\u30e3\u30f3\u3068\u601d\u308f\u308c\u308b\u63a5\u7d9a\u3092\u7834\u68c4<br \/>\niptables -A INPUT -p tcp &#8211;tcp-flags ALL ALL -j DROP<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 80 -j ACCEPT<br \/>\n# HTTPS(SSL)\u3092\u8a31\u53ef<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 443 -j ACCEPT<br \/>\n# FTPD<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 21 -j ACCEPT<br \/>\n#SMTP<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 25 -j ACCEPT<br \/>\n#SMTP(SSL)<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 465 -j ACCEPT<br \/>\n#POP3<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 110 -j ACCEPT<br \/>\n#POP3(SSL)<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 995 -j ACCEPT<br \/>\n#IMAP<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 143 -j ACCEPT<br \/>\n#IMAP(SSL)<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 993 -j ACCEPT<br \/>\n#SMTPS<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 465 -j ACCEPT<br \/>\n#SMTP-Submission<br \/>\niptables -A INPUT -p tcp -m tcp &#8211;dport 587 -j ACCEPT<br \/>\n# PING\u3092\u8a31\u53ef<br \/>\niptables -A INPUT -p icmp -j ACCEPT<br \/>\n<strong># MASQUARADE<br \/>\niptables -t nat -A POSTROUTING -s 192.168.0.0\/24 -o \u25cb\u25cb\u25cb1 -j MASQUERADE<\/strong><br \/>\n# \u8981\u3059\u308b\u306b\u3001\u30ed\u30fc\u30ab\u30eb\u21d4\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306e\u3084\u308a\u53d6\u308a\u3092\u3059\u308b\u306b\u306f<br \/>\n#\u300cNAT\u3068\u306f Network Address Translation\u306e\u7565\u3002 \u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a2\u30c9\u30ec\u30b9\u5909\u63db\u300d\u3068\u3082\u3044\u3046\u3002 LAN\u306b\u63a5\u7d9a\u3055\u308c\u305f\u7aef\u672b\u304b\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u63a5\u7d9a\u3059\u308b\u969b\u306b\u3001\u300c\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8IP\u30a2\u30c9\u30ec\u30b9\u300d\u3092\u81ea\u52d5\u7684\u306b\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3067\u4f7f\u7528\u3067\u304d\u308b\u300c\u30b0\u30ed\u30fc\u30d0\u30ebIP\u30a2\u30c9\u30ec\u30b9\u300d\u306b\u5909\u63db\u3059\u308b\u6a5f\u80fd\u3002\u300d\u304c\u5fc5\u8981\u3068\u3044\u3046\u3053\u3068<br \/>\n# \u305d\u306e\u4ed6<br \/>\n# \u30ed\u30fc\u30ab\u30eb\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u306e\u63a5\u7d9a\u3092\u8a31\u53ef<br \/>\niptables -A INPUT -i lo -j ACCEPT<br \/>\n# \u78ba\u7387\u6e08\u307f\u306e\u901a\u4fe1\u3092\u8a31\u53ef<br \/>\niptables -A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<br \/>\n# \u30ed\u30b0\u3092\u51fa\u529b<br \/>\niptables -A INPUT -j LOG &#8211;log-prefix &#8220;drop_packet:&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u25ce\u9060\u9694\u64cd\u4f5c\u3092\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u3001SSH \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb \u30b5\u30fc\u30d0\u30fc\u30ef\u30fc\u30eb\u30c9\u306e\u8a2d\u5b9a root@Voyager:~# apt -y install openssh-server \u30af\u30e9\u30a4\u30a8\u30f3\u30c8\u5074\u3067\u306f\u3001Windows \u3084 Mac \u3067\u3082 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.nishinari.or.jp\/?p=417\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30b5\u30fc\u30d0\u30fc\u518d\u69cb\u7bc9\u899a\u66f8\uff08004\uff09\u30fc\u30a4\u30f3\u30d5\u30e9\u6574\u5099\uff0801\uff09&#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":{"_crdt_document":"","footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-417","post","type-post","status-publish","format-standard","hentry","category-ubuntu","category-13"],"_links":{"self":[{"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/posts\/417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417"}],"version-history":[{"count":10,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions"}],"predecessor-version":[{"id":480,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions\/480"}],"wp:attachment":[{"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nishinari.or.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}