<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>技術ブログ &#124; 株式会社クラウディア &#187; VPS</title>
	<atom:link href="https://cloudear.jp/blog/?cat=37&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://cloudear.jp/blog</link>
	<description>クラウド専門の業務システム・社内ツール開発</description>
	<lastBuildDate>Fri, 12 Nov 2021 05:00:35 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>さくらの VPS でコピペで使える iptables</title>
		<link>https://cloudear.jp/blog/?p=1149</link>
		<comments>https://cloudear.jp/blog/?p=1149#comments</comments>
		<pubDate>Sun, 24 May 2015 13:12:26 +0000</pubDate>
		<dc:creator><![CDATA[masa]]></dc:creator>
				<category><![CDATA[VPS]]></category>
		<category><![CDATA[インフラ]]></category>
		<category><![CDATA[サーバー]]></category>

		<guid isPermaLink="false">https://cloudear.jp/blog/?p=1149</guid>
		<description><![CDATA[みなさんこんにちは、masa です。今日はインフラネタの中でも、VPS を取り上げたいと思います。AWS や Azure などのクラウドサービスだと画面上から「セキュリティグループ」を設定すれば必要最低限のセキュリティ設 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>みなさんこんにちは、masa です。今日はインフラネタの中でも、VPS を取り上げたいと思います。AWS や Azure などのクラウドサービスだと画面上から「セキュリティグループ」を設定すれば必要最低限のセキュリティ設定はできるのですが、VPS の場合はサーバーにログインして iptables を設定しなくてはいけないことが多いです。<br />
<span id="more-1149"></span>ということで、手っ取り早くコピペで設定する方法をご紹介します。</p>
<p>まずはサーバーに SSH でログインしてください。<br />
次に以下のコマンドで iptables ファイルを開きます。</p>
<pre class="theme:dark-terminal lang:default decode:true"># vim /etc/sysconfig/iptables</pre>
<p>&nbsp;</p>
<p>以下を貼り付けてください。</p>
<pre class="theme:dark-terminal lang:default decode:true "># Generated by iptables-save v1.4.7 on Wed Mar  4 20:57:21 2015
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4:528]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
COMMIT</pre>
<p><strong>7行目： データがないパケットの接続を破棄<br />
8行目： SYNflood（接続をあぶれさせる）攻撃の接続を破棄する<br />
9行目： ステルススキャン（足跡を残さずに空いているポートをスキャンしに来る）接続を破棄する<br />
10行目：localhostからの通信を許可<br />
11行目：Ping通信を許可<br />
12行目以降：各サービスの接続を許可 (SSH, HTTP, POP3, SMTP, SUBMISSION, HTTPS)</strong></p>
<p>必要最低限のものは上で空いています。他にも空けたいポートがある場合は、同じように追記してみてください。</p>
<p>次に、上記設定を iptables へ反映させるため iptables を再起動します。</p>
<pre class="theme:dark-terminal lang:default decode:true "># /etc/sysconfig/iptables restart</pre>
<p>&nbsp;</p>
<p>実際に設定が反映されたか確認してみます。</p>
<pre class="theme:dark-terminal lang:default decode:true"># iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE 
DROP       tcp  --  anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG 
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:submission 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination</pre>
<p>&nbsp;</p>
<p>いかがでしたか？今日は VPS で必要最低限な iptables をする方法をご紹介しました。契約したまま何も設定していないの、裸でゲットーを歩いているのと同じですので すぐに対処してくださいね。</p>
]]></content:encoded>
			<wfw:commentRss>https://cloudear.jp/blog/?feed=rss2&#038;p=1149</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
