<?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>LinuxSense &#187; 多IP</title>
	<atom:link href="http://www.linuxsense.org/archives/tag/%e5%a4%9aip/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxsense.org</link>
	<description>分享Linux技术的点点滴滴</description>
	<lastBuildDate>Sat, 01 Aug 2009 05:23:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux单网卡绑多IP</title>
		<link>http://www.linuxsense.org/archives/419.html</link>
		<comments>http://www.linuxsense.org/archives/419.html#comments</comments>
		<pubDate>Sun, 11 Jan 2009 07:23:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[单网卡]]></category>
		<category><![CDATA[双IP]]></category>
		<category><![CDATA[多IP]]></category>

		<guid isPermaLink="false">http://www.linuxsense.org/?p=419</guid>
		<description><![CDATA[　　在Linux下有时候需要给一个网卡绑定多个IP或者双IP，本文介绍在Redhat系列(redhat,Fedora Core,Centos)中的实现方法和一种在Gentoo等其他Linux中普遍适用的方法。
　　1、单网卡绑定多IP在Redhat系列中的实现方法
　　假设需要绑定多IP的网卡是eth0，请在/etc/sysconfig/network-scripts目录里面创建一个名为ifcfg-eth0:0的文件
　　内容样例为:
　　DEVICE=”eth0:0″
　　IPADDR=”192.168.0.2″
　　BROADCAST=”172.168.0.255″
　　NETMASK=”255.255.255.0″
　　ONBOOT=”yes”
    　其中的DEVICE为设备的名称，

　　IPADDR为此设备的IP地址，
　　BROADCAST是广播地址，
　　NETMASK为子网掩码，
　　ONBOOT 表示在系统启动时自动启动。
　　如果需要再绑定多一个IP地址，
　　只需要把文件名和文件内的DEVICE中的eth0:x加一即可。
　　LINUX最多可以支持255个IP别名
　2、普遍适用的单网卡绑定多IP实现方法
　ifconfig eth0:1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0
　可以把上述命令加在启动自运行文件里面，在Gentoo下是/etc/conf.d/local.start，而某些版本的Linux是/etc/rc.d/rc.local。
　　3、多网卡共用单IP的实现方法
　　使用多块网卡虚拟成为一块网卡，具有相同的IP地址。这项技术其实在sun和cisco中已经存在，分别称为Trunking和 etherchannel技术，在linux中，这种技术称为bonding。因为bonding在内核2.4.x中已经包含了，只需要在编译的时候把网络设备选项中的 Bonding driver support选中就可以了。
　　然后，重新编译核心，重新起动计算机，执行如下命令:
　　ismod bonding
　　ifconfig eth0 down
　　ifconfig eth1 down
　　ifconfig bond0 ipaddress
　　ifenslave bond0 eth0
　　ifenslave bond0 eth1
　　现在两块网卡已经象一块一样工作了，这样可以提高集群节点间的数据传输。
　　你最好把这几句写成一个脚本,再由/etc/rc.d/rc.local或者/etc/conf.d/local.start调用，以便一开机就生效。
　　bonding对于服务器来是个比较好的选择，在没有千兆网卡时，用两三块100兆网卡作 bonding，可大大提高服务器到交换机之间的带宽。但是需要在交换机上设置连接bonding 网卡的两个口子映射为同一个虚拟接口。
]]></description>
			<content:encoded><![CDATA[<p>　　在Linux下有时候需要给一个网卡绑定多个IP或者双IP，本文介绍在Redhat系列(redhat,Fedora Core,Centos)中的实现方法和一种在Gentoo等其他Linux中普遍适用的方法。</p>
<p>　　1、单网卡绑定多IP在Redhat系列中的实现方法</p>
<p>　　假设需要绑定多IP的网卡是eth0，请在/etc/sysconfig/network-scripts目录里面创建一个名为ifcfg-eth0:0的文件<br />
　　内容样例为:</p>
<p>　　DEVICE=”eth0:0″<br />
　　IPADDR=”192.168.0.2″<br />
　　BROADCAST=”172.168.0.255″<br />
　　NETMASK=”255.255.255.0″<br />
　　ONBOOT=”yes”</p>
<p>    　其中的DEVICE为设备的名称，<br />
<span id="more-419"></span></p>
<p>　　IPADDR为此设备的IP地址，</p>
<p>　　BROADCAST是广播地址，</p>
<p>　　NETMASK为子网掩码，</p>
<p>　　ONBOOT 表示在系统启动时自动启动。</p>
<p>　　如果需要再绑定多一个IP地址，</p>
<p>　　只需要把文件名和文件内的DEVICE中的eth0:x加一即可。</p>
<p>　　LINUX最多可以支持255个IP别名</p>
<p>　2、普遍适用的单网卡绑定多IP实现方法</p>
<p>　ifconfig eth0:1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0<br />
　可以把上述命令加在启动自运行文件里面，在Gentoo下是/etc/conf.d/local.start，而某些版本的Linux是/etc/rc.d/rc.local。</p>
<p>　　3、多网卡共用单IP的实现方法</p>
<p>　　使用多块网卡虚拟成为一块网卡，具有相同的IP地址。这项技术其实在sun和cisco中已经存在，分别称为Trunking和 etherchannel技术，在linux中，这种技术称为bonding。因为bonding在内核2.4.x中已经包含了，只需要在编译的时候把网络设备选项中的 Bonding driver support选中就可以了。</p>
<p>　　然后，重新编译核心，重新起动计算机，执行如下命令:</p>
<p>　　ismod bonding<br />
　　ifconfig eth0 down<br />
　　ifconfig eth1 down<br />
　　ifconfig bond0 ipaddress<br />
　　ifenslave bond0 eth0<br />
　　ifenslave bond0 eth1<br />
　　现在两块网卡已经象一块一样工作了，这样可以提高集群节点间的数据传输。</p>
<p>　　你最好把这几句写成一个脚本,再由/etc/rc.d/rc.local或者/etc/conf.d/local.start调用，以便一开机就生效。</p>
<p>　　bonding对于服务器来是个比较好的选择，在没有千兆网卡时，用两三块100兆网卡作 bonding，可大大提高服务器到交换机之间的带宽。但是需要在交换机上设置连接bonding 网卡的两个口子映射为同一个虚拟接口。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxsense.org/archives/419.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
