Linux各版本上的多网卡绑定
时间:2006-09-22 来源:zrover
Linux上很容易可以将多块网卡绑定,实现负载均衡和双线热备的功能。 负载均衡即将负载平均的分配到任意多块网卡上面,实现带宽的叠加 双线热备即多块网卡互为备份,任何一块能够工作即可保证网络正常运行。 各个绑定类型的分别 mode=0 Round-robin: sequential(轮询负载均衡,最常用) mode=1 Active-backup: only one mode=2 XOR: same MAC same nic mode=3 Broadcast: all 各大发行版略有不同,基本上分成3种,2036 一块网卡如何绑定两个ip(linuxloveu) #cd /etc/sysconfig/network-scripts #cp ifcfg-eth0 ifcfg-eth0:1 #vi ifcfg-eth0:1 修改IP和设备名 Debian下一个网卡绑定多个ip的方法(NetDC) 修改/etc/network/interfaces auto eth0 iface eth0 inet static address 172.16.3.123 netmask 255.255.255.0 network 172.16.3.0 broadcast 172.16.3.255 gateway 172.16.3.1 auto eth0:1 iface eth0:1 inet static address 10.16.3.123 netmask 255.255.0.0 network 10.16.0.0 broadcast 10.16.255.255 修改/etc/network/ifstate lo=lo eth0=eth0 eth0:1=eth0:1 然后/etc/init.d/networking restart就可以了。 一个网卡绑定多ip另一法(hotbox) 在/etc/sysconfig/network-scripts/下创建一个文件:ifcfg-ethX-rangeX ("X"为网卡号) 文件内容: IPADDR_START=<start ip> IPADDR_END=<end ip> CLONENUM=0 可以有256个ip 2037 一个ip如何绑定两块网卡(hutuworm) 假设192.168.0.88是ip,192.168.0.1是网关: /sbin/modprobe bonding miimon=100 mode=1 /sbin/ifdown eth0 /sbin/ifdown eth1 /sbin/ifconfig bond0 192.168.0.88 /sbin/ifenslave bond0 eth0 eth1 /sbin/route add default gw 192.168.0.1 2038 192.168.1.0/24(双眼皮的猪) 它与192.168.1.0/255.255.255.0是等价的,只是表示方式不同.... Debian下 Debian和Ubuntu, SuSE, Mandriva、Fedora和RH ----------------------------------------------------------------------- Debian和Ubuntu上的多网卡绑定 实验环境Ubuntu 6.06 Dadder,内核版本2.6.15-23 server 首先安装ifenslave #apt-get install ifenslave-2.6 编辑/etc/network/interfaces auto lo bond0 eth0 eth1 iface bond0 inet static address 10.31.1.5 netmask 255.255.255.0 network 10.31.1.0 gateway 10.31.1.254 up /sbin/ifenslave bond0 eth0 up /sbin/ifenslave bond0 eth1 iface lo loopback iface eth0 inet static address 10.1.1.101 netmask 255.255.255.0 iface eth1 inet static address 10.1.1.102 netmask 255.255.255.0 再编辑 /etc/modprobe.d/arch/i386 加上两行: alias bond0 bonding options bonding mode=0 miimon=100 最后重启网络即可 /etc/init.d/networking restart ----------------------------------------------------------------------- SuSE,Mandriva、Fedora和RH 1、编辑 /etc/modules.conf 文件(SuSE的系统是/etc/modprobe.d/modprobe.cong.local),加入如下一行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0 alias bond0 bonding 2、编辑虚拟网络接口配置文件,指定网卡IP vi /etc/sysconfig/network-scripts/ifcfg-bond0 (SuSE的系统是/etc/sysconfig/network/ifcfg-bond0) Fedora的写法
DEVICE=bond0
SuSE的写法
BOOTPROTO='static' 3、编辑物理网络接口配置文件,并指向虚拟网络接口bond0
Fedora:
ifcfg-eth0对应第一个网卡,ifcfg-eth1对应第二个千兆网卡。
ifcfg-eth1 : SuSE:
物理网络接口配置文件位于/etc/sysconfig/network/,
BOOTPROTO='static'
最后编辑/etc/rc.local(SuSE是/etc/rc.d/rc)或是直接运行 无论eth0 eth1 eth2的IP怎样设置,绑定之后全都以bind0的设置为准。此时所有网卡的mac地址都是一样的。 |