<?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</title>
	<atom:link href="https://www.fuwuqiok.com/tag/vpc/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网络无EIP的主机上网问题</title>
		<link>https://www.fuwuqiok.com/%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e9%98%bf%e9%87%8c%e4%ba%91vpc%e7%bd%91%e7%bb%9c%e6%97%a0eip%e7%9a%84%e4%b8%bb%e6%9c%ba%e4%b8%8a%e7%bd%91%e9%97%ae%e9%a2%98/</link>
		<comments>https://www.fuwuqiok.com/%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e9%98%bf%e9%87%8c%e4%ba%91vpc%e7%bd%91%e7%bb%9c%e6%97%a0eip%e7%9a%84%e4%b8%bb%e6%9c%ba%e4%b8%8a%e7%bd%91%e9%97%ae%e9%a2%98/#comments</comments>
		<pubDate>Fri, 14 Aug 2015 14:08:06 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[aliyun服务器代维]]></category>
		<category><![CDATA[EIP]]></category>
		<category><![CDATA[VPC]]></category>
		<category><![CDATA[如何解决阿里云VPC网络无EIP的主机上网问题]]></category>

		<guid isPermaLink="false">https://www.fuwuqiok.com/?p=2534</guid>
		<description><![CDATA[<p>问题由来 阿里云的VPC与其他基于OpenStack的IaaS不同，他的路由只是作为多网段的路由交换， 不提供 [&#8230;]</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e9%98%bf%e9%87%8c%e4%ba%91vpc%e7%bd%91%e7%bb%9c%e6%97%a0eip%e7%9a%84%e4%b8%bb%e6%9c%ba%e4%b8%8a%e7%bd%91%e9%97%ae%e9%a2%98/">如何解决阿里云VPC网络无EIP的主机上网问题</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></description>
				<content:encoded><![CDATA[<h1 id="问题由来">问题由来</h1>
<p>阿里云的VPC与其他基于OpenStack的IaaS不同，他的路由只是作为多网段的路由交换， 不提供内到外的路由，因此在VPC内的主机除非绑定EIP，否则是无法连接公网的。通过工单询问客服，得到的结论是通过在路由器上添加一个路由，通过一个 绑定EIP的主机做NAT上网，通过设置iptables的方式来实现。</p>
<h1 id="VPC结构图">VPC结构图</h1>
<p><a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/aliyun-vpc-snat.jpg"><img class="attachment-medium" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/aliyun-vpc-snat.jpg" alt="aliyun-vpc-snat" width="523" height="472" /></a></p>
<h1 id="虚拟路由器配置">虚拟路由器配置</h1>
<h2 id="添加路由">添加路由</h2>
<p>为了让内网服务器借助EIP访问公网，所以设置所有目标地址0.0.0.0/0下一跳都转发到绑定了公网IP的ECS实例上。这里的下一跳ECS不支持搜索，需要提前记号名称：</p>
<p><a href="https://www.fuwuqiok.com/wp-content/uploads/2015/08/aliyun-vpc-snat-2.jpg"><img class="attachment-medium" src="https://www.fuwuqiok.com/wp-content/uploads/2015/08/aliyun-vpc-snat-2.jpg" alt="aliyun-vpc-snat-2" width="264" height="234" /></a></p>
<h1 id="绑定EIP的主机配置">绑定EIP的主机配置</h1>
<h2 id="iptables添加SNAT规则">iptables添加SNAT规则</h2>
<figure class="highlight bash">
<table>
<tbody>
<tr>
<td class="code">
<pre><span class="line">iptables -t nat -I POSTROUTING <span class="operator">-s</span> <span class="number">192.168</span>.<span class="number">2.0</span>/<span class="number">24</span> -j SNAT --to-source <span class="number">192.168</span>.<span class="number">2.20</span></span></pre>
</td>
</tr>
</tbody>
</table>
</figure>
<blockquote><p><strong>注意：</strong> ubuntu 14.04 系统保存iptables设置需要安装iptables-persistent包，然后通过 <code>service iptables-persistent save</code> 的方式保存配置，安装完iptables-persistent后该服务随系统一起启动并会把保存的配置应用</p></blockquote>
<h2 id="开启IP转发">开启IP转发</h2>
<figure class="highlight bash">
<table>
<tbody>
<tr>
<td class="code">
<pre><span class="line"><span class="built_in">echo</span> <span class="string">"net.ipv4.ip_forward=1"</span> &gt;&gt;  /etc/sysctl.conf &amp;&amp; sysctl -p</span></pre>
</td>
</tr>
</tbody>
</table>
</figure>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e9%98%bf%e9%87%8c%e4%ba%91vpc%e7%bd%91%e7%bb%9c%e6%97%a0eip%e7%9a%84%e4%b8%bb%e6%9c%ba%e4%b8%8a%e7%bd%91%e9%97%ae%e9%a2%98/">如何解决阿里云VPC网络无EIP的主机上网问题</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.fuwuqiok.com/%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e9%98%bf%e9%87%8c%e4%ba%91vpc%e7%bd%91%e7%bb%9c%e6%97%a0eip%e7%9a%84%e4%b8%bb%e6%9c%ba%e4%b8%8a%e7%bd%91%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
