常用操作系统双网卡绑定方法目录一、RHEL 5.7 LINUX 下网卡绑定设置 (1)二、RHEL6 LINUX 下网卡绑定设置 (3)三、SUSE 10 下网卡绑定设置 (11)四、SUSE 11 下网卡绑定设置 (16)五、Windows 下网卡绑定设置 (22)一、RHEL 5.7 LINUX 下网卡绑定设置[root@Linux5 ~]# more /etc/sysconfig/network-scripts/ifcfg-bond0# Broadcom Corporation NetXtreme II BCM5709S Gigabit EthernetDEVICE=bond0BOOTPROTO=staticONBOOT=yesIPADDR=10.96.19.207NETMASK=255.255.255.0GATEWAY=10.96.19.1TYPE=Ethernet[root@Linux5 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0# Broadcom Corporation NetXtreme II BCM5709S Gigabit EthernetDEVICE=eth0BOOTPROTO=noneHWADDR=34:40:B5:BD:24:18ONBOOT=yesMASTER=bond0SLAVE=yesTYPE=Ethernet[root@Linux5 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth1# Broadcom Corporation NetXtreme II BCM5709S Gigabit EthernetDEVICE=eth1BOOTPROTO=noneHWADDR=34:40:B5:BD:24:1AONBOOT=yesMASTER=bond0SLAVE=yesTYPE=Ethernet[root@Linux5 ~]# more /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: eth0MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: eth0MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 6Permanent HW addr: 34:40:b5:bd:24:18Slave Interface: eth1MII Status: downSpeed: 1000 MbpsDuplex: fullLink Failure Count: 6Permanent HW addr: 34:40:b5:bd:24:1a[root@Linux5 ~]# more /etc/modprobe.confalias eth0 bnx2alias eth1 bnx2alias eth2 bnx2alias eth3 bnx2alias scsi_hostadapter mptbasealias scsi_hostadapter1 mptsasalias scsi_hostadapter2 usb-storagealias net-pf-10 offalias ipv6 offoptions ipv6 disable=1alias usb0 usbnetalias usb1 usbnetalias bond0 bondingoptions bond0 miimon=100 mode=1 primary=eth0关于路由的配置,做如下说明,1)使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法://添加到主机的路由# route add –host 192.168.168.110 dev eth0# route add –host 192.168.168.119 gw 192.168.168.1//添加到网络的路由# route add –net IP网段 netmask MASK eth0# route add –net IP网段 netmask MASK gw IP# route add –net IP网段 /24 eth1//添加默认网关# route add default gw IP//删除路由# route del –host 192.168.168.110 dev eth02)在linux下设置永久路由的方法(选其一即可)a. 将命令写入开机脚本/etc/rc.localb. route add -net 192.168.3.0/24 dev eth0route add -net 192.168.2.0/24 gw 192.168.3.254c. /etc/sysconfig/static-router :any net x.x.x.x/24 gw y.y.y.y二、RHEL6 LINUX 下网卡绑定设置To configure the bond0 device with the network interface eth0 and eth1, perform the following steps:1. Create a new file as root named bonding.conf in the /etc/modprobe.d/ directory. Insert the following line in this new file:alias bond0 bonding2. Create the channel bonding interface file ifcfg-bond0 inthe/etc/sysconfig/network-scripts/ directory:# cat /etc/sysconfig/network-scripts/ifcfg-bond0DEVICE=bond0IPADDR=192.168.50.111NETMASK=255.255.255.0USERCTL=noBOOTPROTO=noneONBOOT=yesBONDING_OPTS="mode=1 miimon=100"Note:Configure the bonding parameters in the file /etc/sysconfig/network-scripts/ifcfg-bond0, as above, BONDING_OPTS="mode=0 miimon=100".The behavior of the bonded interfaces depends upon the mode. The mode 0 is the default value, which causes bonding to set all slaves of an active-backup bond to the same MAC address at enslavement time. For more information about the bonding modes, refer to The bonding modes supported in Red Hat Enterprise Linux.3. Configure the ethernet interface in the file/etc/sysconfig/network-scripts/ifcfg-eth0. Both eth0 and eth1 should look like thefollowing example:DEVICE=eth<N>BOOTPROTO=noneHWADDR=54:52:00:26:90:fcONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=no4. Restart the network service:# service network restartNote:It may be necessary to disable NetworkManager if you find that bonding is not working properly. To do this, you would run the following:# service NetworkManager stop# chkconfig NetworkManager off# service Network restart5. In order to check the bonding status, check the following file:# cat /proc/net/bonding/bond0Multiple bonded deviceConfiguring multiple bonding channels is similar to configuring a single bonding channel. Setup the ifcfg-bond<N> and ifcfg-eth<X> files as if there were only one bonding channel. You can specify different BONDING_OPTS for different bonding channels so that they can have different modes and other settings. Refer to the section 4.2.2. Channel Bonding Interfaces in the Red Hat Enterprise Linux 6 Deployment Guide for more information.To configure the bond0 device with the ethernet interface eth0 and eth1, and configure the bond1 device with the Ethernet interface eth2 and eth3, perform the following steps: 1. Create configuration file /etc/modprobe.d/bonding.conf with the following lines: alias bond0 bondingalias bond1 bonding2. Create the channel bonding interface files ifcfg-bond0 and ifcfg-bond1, in the/etc/sysconfig/network-scripts/ directory:# cat /etc/sysconfig/network-scripts/ifcfg-bond0DEVICE=bond0IPADDR=192.168.50.111NETMASK=255.255.255.0USERCTL=noBOOTPROTO=noneONBOOT=yesBONDING_OPTS="mode=1 miimon=100"# cat /etc/sysconfig/network-scripts/ifcfg-bond1DEVICE=bond1IPADDR=192.168.30.111NETMASK=255.255.255.0USERCTL=noBOOTPROTO=noneONBOOT=yesBONDING_OPTS="mode=1 miimon=50"Note: there are different bonding modes for bond0 and bond1. For the bond0 device, it is the balance-rr policy (mode=0).For the bond1 device, it is the fail_over_mac policy (mode=1). More information about the bonding modes please refer to The bonding modes supported in Red Hat Enterprise Linux3. Configure the ethernet interface in the file/etc/sysconfig/network-scripts/ifcfg-eth0. Both eth0 and eth1 should look like thefollowing example:DEVICE=eth<N>BOOTPROTO=noneHWADDR=54:52:00:26:90:fcONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=noNote:Replace <N> with the numerical value for the interface, such as 0 and 1 in this example. Replace the HWADDR value with the MAC for the interface.Red Hat suggest that configure the MAC address of the ethernet card into the file /etc/sysconfig/network-scripts/ifcfg-eth<N>.4. Restart the network service:# service network restart5. In order to check the bonding status, check the following file:# cat /proc/net/bonding/bond0Bonding modesBalance-rr (mode 0)Round-robin policy: transmits packets in sequential order from the first available slave through the last.∙This mode provides load balancing and faulttolerance.Active-backup (mode 1)Active-backup policy: only one slave in the bond is active. A different slave becomes active only if the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch.In bonding version 2.6.2 or later, when a failover occurs in active-backup mode, bonding will issue one or more gratuitous ARPs on the newly active slave. One gratuitous ARP is issued for the bonding master interface and each VLAN interface configured above it, assuming that the interface has at least one IP address configured. Gratuitous ARPs issued for VLAN interfaces are tagged with the appropriate VLAN id.∙This mode provides fault tolerance.∙The primary option, affects the behavior of thismode.Balance-xor (mode 2)XOR policy: transmits based on the selected transmit hash policy. The default policy is a simple ((source MAC address XORd with destination MAC address) modulo slave count) . Alternate transmit policies may be selected via the xmit_hash_policy option, described below.∙This mode provides load balancing and faulttolerance.Broadcast (mode 3)Broadcast policy: transmits everything on all slave interfaces.∙This mode provides fault tolerance.802.3ad (mode 4)IEEE 802.3ad dynamic link aggregation: this mode creates aggregation groups that share the same speed and duplex settings, and uses all slaves in the active aggregator according to the 802.3ad specification. Slave selection for outgoing traffic is done according to the transmit hash policy, which may be changed from the default simple XOR policy via the xmit_hash_policy option, documented below. Note that not all transmit policies may be 802.3ad compliant, particularly with regard to the packet misordering requirements described in section 43.2.4 of the 802.3ad standard. Differing peer implementations will have varying tolerances for noncompliance. Prerequisites:∙ethtool support in the base drivers for retrieving thespeed and duplex of each slave∙ a switch that supports IEEE 802.3ad Dynamic linkaggregation.∙Most switches will require some type of configurationto enable 802.3ad mode.Balance-tlb (mode 5)Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.Prerequisite:∙ethtool support in the base drivers for retrieving thespeed of each slave.Balance-alb (mode 6)Adaptive load balancing: includes balance-tlb and receive load balancing (rlb) for IPv4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond, such that different peers use different hardware addresses for the server.Receive traffic from connections created by the server is also balanced. When the local system sends an ARP request the bonding driver copies and saves the peer's IP information from the ARP packet. When the ARP reply arrives from the peer, its hardware address is retrieved and the bonding driver initiates an ARP reply to this peer assigning it to one of the slaves in the bond. A problematic outcome of using ARP negotiation for balancing is that each time that an ARP request is broadcast it uses the hardware address of the bond. Hence, peers learn the hardware address of the bond and the balancing of receive traffic collapses to the current slave. This is handled by sending updates (ARP Replies) to all the peers with their individually assigned hardware address such that the traffic is redistributed. Receive traffic is also redistributed when a new slave is added to the bond and when an inactive slave is reactivated. The receive load is distributed sequentially (round-robin) among the group of highest-speed slaves in the bond.When a link is reconnected or a new slave joins the bond the receive traffic is redistributed among all active slaves in the bond by initiating ARP Replies with the selected MAC address to each of the clients. The updelay parameter (detailed below) must be set to a value equal or greater than the switch's forwarding delay so that the ARP Replies sent to the peers will not be blocked by the switch.Prerequisites:ethtool support in the base drivers for retrieving thespeed of each slave∙base driver support for setting the hardware addressof a device while it is open. This is required so thatthere will always be one slave in the team using thebond hardware address (the curr_active_slave) whilehaving a unique hardware address for each slave inthe bond. If the curr_active_slave fails its hardwareaddress is swapped with the new curr_active_slavethat was chosen.Bonding parameters in generalIt is critical that either the miimon or arp_interval and arp_ip_target parameters be specified, otherwise serious network degradation will occur during link failures. Very few devices do not support at least miimon, so it should always be used.General bonding parametersmax_bonds: specifies the number of bonding devices to create for this instance of the bonding driver. For example, if max_bonds is 3, and the bonding driver is not already loaded, then bond0, bond1 and bond2 will be created. The default value is 1.ARP monitoring parameters∙arp_interval: specifies the ARP link monitoringfrequency in milliseconds.∙arp_ip_target: specifies the IP addresses to use asARP-monitoring peers when arp_interval is > 0.Multiple IP addresses must be separated by a comma.At least one IP address must be given for ARPmonitoring to function. The maximum number oftargets that can be specified is 16.∙arp_validate: specifies whether or not ARP probesand replies should be validated in the active-backupmode. This causes the ARP monitor to examine theincoming ARP requests and replies, and only considera slave to be up if it is receiving the appropriate ARPtraffic. This parameter can have the followingvalues:o none (0). This is the default.o active (1). Validation is performed only for theactive slave.o backup (2). Validation is performed only for backupslaves.o all (3). Validation is performed for all slaves.三、SUSE 10 下网卡绑定设置命令方式如下1)、配置网卡bondingA、在/etc/sysconfig/network 下建立bond0 配置文件,设置好网络地址,网关子网掩码#vi /etc/sysconfig/network/ifcfg-bond0BOOTPROTO='static'BROADCAST=''#此参数无需设置IPADDR='10.30.43.4'NETMASK='255.255.255.128'NETWORK=''#此参数最好在网关配置文件里配置,这里无需设置BONDING_MASTER='yes'BONDING_MODULE_OPTS='mode=active-backup miimon=100'BONDING_SLAVE0='bus-pci-0000:06:08.1'#如果能确认网卡总线可以这么设置,也可以采用MAC地址方式,如BONDING_SLAVE0='id-00:0c:29:3b:f8:4b'BONDING_SLAVE1='bus-pci-0000:06:09.1'STARTMODE='auto'USERCONTROL='no'B、修改需要绑定的两个网卡的配置文件#可以直接删除两个网卡的配置文件#vi /etc/sysconfig/network/ifcfg-eth-id-xx:xx:xx:xx:xx:xx,BOOTPROTO='none'STARTMODE='off'C、输入#cat /proc/net/bonding/bond0看网卡工作状态,查看到bond0,eth0,eth1是否正常2)、网络信息设置A、编辑网关的配置,建议在默认路由里配置#vi /etc/sysconfig/network/routesdefault 10.25.5.254 - -b、设置ip地址通过 yast2 lan 进行设置。