sudo gedit /etc/network/interfaces
照上边eth0添加eth0:0
auto eth0
iface eth0 inet static
name Ethernet Lan card
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
auto eth0:0
iface eth0:0 inet static
name Ethernet Lan card
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
然后重启服务
sudo /etc/init.d/networking restart
测试新的ip地址
ping 192.168.0.1 ping 192.168.0.2
多个网卡绑定一个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调用,
以便一开机就生效。
bonding对于服务器来是个比较好的选择,在没有千兆网卡时,
用两三块100兆网卡作 bonding,可大大提高服务器到交换机之间的带宽。
但是需要在交换机上设置连接bonding 网卡的两个口子映射为同一个虚拟接口。