<?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>服务器安全维护工作室 &#187; 阿里云VPC配置SNAT上外网教程</title>
	<atom:link href="https://www.fuwuqiok.com/tag/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fuwuqiok.com</link>
	<description></description>
	<lastBuildDate>Sun, 01 Mar 2020 07:28:40 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.26</generator>
	<item>
		<title>阿里云VPC配置SNAT上外网教程</title>
		<link>https://www.fuwuqiok.com/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/</link>
		<comments>https://www.fuwuqiok.com/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/#comments</comments>
		<pubDate>Fri, 14 Aug 2015 14:13:38 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[aliyun服务器代维]]></category>
		<category><![CDATA[阿里云VPC配置SNAT上外网教程]]></category>

		<guid isPermaLink="false">https://www.fuwuqiok.com/?p=2538</guid>
		<description><![CDATA[<p>包括AWS阿里云在内的很多云服务器classcal下都不支持SNAT，有客户拿到了阿里云VPC的测试权限，让们 [&#8230;]</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/">阿里云VPC配置SNAT上外网教程</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>包括AWS阿里云在内的很多云服务器classcal下都不支持SNAT，有客户拿到了阿里云VPC的测试权限，让们工作室帮忙测试这个虚拟专用网模式下是支持SNAT的，在此将测试过程大概列一下操作过程。<span id="more-498"></span></p>
<pre>使用一台虚拟路由器，两台虚拟交换机用于连接内网局域网和外网机器所属的局域网，两台ECS:
一台纯内网，一台绑定了EIP作为NAT网关，如下：</pre>
<p>&nbsp;</p>
<p><a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/1.jpg"><img class="attachment-medium" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/1.jpg" alt="1" width="674" height="502" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<pre>在虚拟路由器上配置路由</pre>
<p>由于为了让内网服务器借助EIP访问公网，所以设置所有目标地址0.0.0.0/0下一跳都转发到绑定了公网IP的ECS实例上。这里的下一跳ECS不支持搜索，有点麻烦。</p>
<p><a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/２.jpg"><img class=" size-full wp-image-2544 alignleft" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/２.jpg" alt="２" width="264" height="234" /></a></p>
<p>&nbsp;</p>
<pre>






配置好之后，登陆外网机器配置SNAT</pre>
<div id="highlighter_159726" class="syntaxhighlighter  ">
<div class="lines">
<div class="line alt1">
<table>
<tbody>
<tr>
<td class="number"><code>1</code></td>
<td class="content"><code class="plain">iptables -t nat -I POSTROUTING -s 172.16.3.0/24 -j SNAT --to-</code><code class="functions">source</code> <code class="plain">172.16.1.2</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>其中3网段是内网局域网的网段，172.16.1.2是绑定了EIP的ECS自身IP，以便完成源地址转换</p>
<p><a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/31.jpg"><img class="attachment-medium" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/31.jpg" alt="31" width="817" height="167" /></a></p>
<p>&nbsp;</p>
<pre>然后修改内核参数允许IP转发：</pre>
<div id="highlighter_391918" class="syntaxhighlighter  ">
<div class="lines">
<div class="line alt1">
<table>
<tbody>
<tr>
<td class="number"><code>1</code></td>
<td class="content"><code class="functions">sed</code> <code class="plain">-i </code><code class="string">'s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g'</code> <code class="plain">/etc/sysctl.conf;sysctl -p</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>完成后测试，内网服务器已经可以访问外网了: <a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/5.jpg"><img class="attachment-medium" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/5.jpg" alt="5" width="912" height="263" /></a></p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/">阿里云VPC配置SNAT上外网教程</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.fuwuqiok.com/%e9%98%bf%e9%87%8c%e4%ba%91vpc%e9%85%8d%e7%bd%aesnat%e4%b8%8a%e5%a4%96%e7%bd%91%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
