压在透明的玻璃上c-国产精品国产一级A片精品免费-国产精品视频网-成人黄网站18秘 免费看|www.tcsft.com

linux下綁定雙網卡

  系統環境:

  操作系統: RedHat EL55

  雙網卡綁定單個IP 地址為了提供網絡的高可用性,我們可能需要將多塊網卡綁定成一塊虛擬網卡對外提供服務,這樣即使其中的一塊物理網卡出現故障,也不會導致連接中斷。

  為了提供網絡的高可用性,我們可能需要將多塊網卡綁定成一塊虛擬網卡對外提供服務,這樣即使其中的一塊物理網卡出現故障,也不會導致連接中斷。在Linux下叫bonding,IBM稱為etherchanel,broadcom叫team

  1、查看內核是否支持網卡綁定

  [root@bjsrv ~]# modinfo bonding

  filename:       /lib/modules/2.6.18-194.el5xen/kernel/drivers/net/bonding/bonding.ko

  author:         Thomas Davis, tadavis@lbl.gov and many others

  description:    Ethernet Channel Bonding Driver, v3.4.0

  version:        3.4.0

  license:        GPL

  srcversion:     A2FB5CCCDB38BE9A099CC9C

  depends:        ipv6

  vermagic:       2.6.18-194.el5xen SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1

  parm:           max_bonds:Max number of bonded devices (int)

  parm:           num_grat_arp:Number of gratuitous ARP packets to send on failover event (int)

  parm:           num_unsol_na:Number of unsolicited IPv6 Neighbor Advertisements packets to send on failover event (int)

  parm:           miimon:Link check interval in milliseconds (int)

  parm:           updelay:Delay before considering link up, in milliseconds (int)

  parm:           downdelay:Delay before considering link down, in milliseconds (int)

  parm:           use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int)

  parm:           mode:Mode of operation : 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)

  parm:           primary:Primary network device to use (charp)

  parm:           primary_reselect:Reselect primary slave once it comes up; 0 for always (default), 1 for only if speed of primary is better, 2 for only on active slave failure (charp)

  parm:           lacp_rate:LACPDU tx rate to request from 802.3ad partner (slow/fast) (charp)

  parm:           xmit_hash_policy:XOR hashing method: 0 for layer 2 (default), 1 for layer 3+4 (charp)

  parm:           arp_interval:arp interval in milliseconds (int)

  parm:           arp_ip_target:arp targets in n.n.n.n form (array of charp)

  parm:           arp_validate:validate src/dst of ARP probes: none (default), active, backup or all (charp)

  parm:           fail_over_mac:For active-backup, do not set all slaves to the same MAC.  none (default), active or follow (charp)

  parm:           debug:Print debug messages; 0 for off (default), 1 for on (int)

  module_sig:     883f3504ba03af81e1fa4939f6a629311282410a0c9263f8f3007023d923512d2ecbb7e81cefc609f41f79cd9bf13e480d0b17e94899d3c4408c6a6

  [root@bjsrv ~]#

  2、配置虛擬網卡

  [root@bjsrv ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-bond0

  [root@bjsrv ~]#

  [root@bjsrv ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0

  # Intel Corporation 82540EM Gigabit Ethernet Controller

  DEVICE=bond0

  BOOTPROTO=static

  IPADDR=192.168.10.254

  NETMASK=255.255.255.0

  GATEWAY=192.168.10.1

  ONBOOT=yes

  [root@bjsrv ~]#

  [root@bjsrv ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

  # Intel Corporation 82540EM Gigabit Ethernet Controller

  DEVICE=eth1

  BOOTPROTO=none

  ONBOOT=yes

  MASTER=bond0

  SLAVE=yes

  [root@bjsrv ~]#

  [root@bjsrv ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth2

  # Intel Corporation 82540EM Gigabit Ethernet Controller

  DEVICE=eth2

  BOOTPROTO=none

  ONBOOT=yes

  MASTER=bond0

  SLAVE=none

  [root@bjsrv ~]#

  [root@bjsrv ~]# grep  bond /etc/modprobe.d/modprobe.conf.dist

  alias bond0 bonding

  options bond0 miimon=100 mode=1

  [root@bjsrv ~]# grep  bond /etc/modprobe.conf

  alias bond0 bonding

  options bond0 miimon=100 mode=1

  三、參數說明

  options bond0 miimon=100 mode=1

  如果達到負載均衡的目的,應該是0,1是熱備狀態。

  miimon是毫秒數,每100毫秒觸發檢測線路穩定性的事件。

  mode= 是ifenslave的工作狀態。

  一共有7種方式:

  =0: (balance-rr) Round-robin policy: (平衡掄循環策略):傳輸數據包順序是依次傳輸,直到最后一個傳輸完畢,

  此模式提供負載平衡和容錯能力,這需要設置交換機的配合才能完成。

  =1: (active-backup) Active-backup policy:(主-備份策略):只有一個設備處于活動狀態。

  一個宕掉另一個馬上由備份轉換為主設備。mac地址是外部可見得。 此模式提供了容錯能力。

  =2:(balance-xor) XOR policy:(廣播策略):將所有數據包傳輸給所有接口。 此模式提供了容錯能力。

  =3:(balance-xor) XOR policy:   (平衡 策略): 傳輸根據原地址布爾值選擇傳輸設備。

  此模式提供負載平衡和容錯能力。

  =4:(802.3ad) IEEE 802.3ad Dynamic link aggregation.

  IEEE 802.3ad 動態鏈接聚合:創建共享相同的速度和雙工設置的聚合組。

  =5:(balance-tlb) Adaptive transmit load balancing(適配器傳輸負載均衡)

  :沒有特殊策略,第一個設備傳不通就用另一個設備接管第一個設備正在處理的mac地址,幫助上一個傳。

  =6:(balance-alb) Adaptive load balancing: (適配器傳輸負載均衡):大致意思是包括mode5,bonding驅動程序截獲 ARP 在本地系統發送出的請求,用其中之一的硬件地址覆蓋從屬設備的原地址。就像是在服務器上不同的人使用不同的硬件地址一樣。

  四、重新啟動網絡服務

  [root@bjsrv ~]#service network restart

  Shutting down interface bond0:  [  OK  ]

  Shutting down interface eth0:  [  OK  ]

  Shutting down loopback interface:  [  OK  ]

  Bringing up loopback interface:  [  OK  ]

  Bringing up interface bond0:  [  OK  ]

  Bringing up interface eth0:  [  OK  ]

  五、查看虛擬網卡信息

  [root@bjsrv ~]# cat /proc/net/bonding/bond0

  Ethernet Channel Bonding Driver: v3.4.0 (October 7, 2008)

  Bonding Mode: fault-tolerance (active-backup)

  Primary Slave: None

  Currently Active Slave: eth1

  MII Status: up

  MII Polling Interval (ms): 100

  Up Delay (ms): 0

  Down Delay (ms): 0

  Slave Interface: eth1

  MII Status: up

  Link Failure Count: 0

  Permanent HW addr: 08:00:27:99:ce:df

  Slave Interface: eth2

  MII Status: up

  Link Failure Count: 0

  Permanent HW addr: 08:00:27:ce:7a:4d

  [root@bjsrv ~]#

  [root@bjsrv ~]# netstat -nr

  Kernel IP routing table

  Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

  192.168.10.0    0.0.0.0         255.255.255.0   U         0 0          0 bond0

  192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

  192.168.8.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

  169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0

  0.0.0.0         192.168.10.1    0.0.0.0         UG        0 0          0 bond0

  [root@bjsrv ~]#

  六、down 掉主網卡測試

  在測試中,主網卡down 后,會有連接超時,但會立刻聯通備份網卡!

  查看虛擬網卡狀態:

  [root@bjsrv ~]# cat /proc/net/bonding/bond0

  Ethernet Channel Bonding Driver: v3.4.0 (October 7, 2008)

  Bonding Mode: fault-tolerance (active-backup)

  Primary Slave: None

  Currently Active Slave: eth2

  MII Status: up

  MII Polling Interval (ms): 100

  Up Delay (ms): 0

  Down Delay (ms): 0

  Slave Interface: eth1

  MII Status: down

  Link Failure Count: 1

  Permanent HW addr: 08:00:27:99:ce:df

  Slave Interface: eth2

  MII Status: up

  Link Failure Count: 0

  Permanent HW addr: 08:00:27:ce:7a:4d

  [root@bjsrv ~]#

 

上一篇:安卓防火墻 PS DroidWall

下一篇:AIX常用命令