将两张网卡绑定,共用一个IP,实现冗余效果。实际上linux双网卡的绑定模式有7种:
apt-get install ifenslave
vi /etc/modules
添加
bonding mode=0 miimon=100
miimon是10ms监测一次网卡状态
注:bond IP与成员口的IP不能一致,如果不想成员口IP获得本网段地址,可以随便配置一个。
auto lo
iface lo inet loopback
auto em2
iface em2 inet static
address 192.168.1.12
netmask 255.255.0.0
#bond-master bond0
auto em5
iface em5 inet static
address 192.168.1.11
netmask 255.255.0.0
#bond-master bond0
auto bond0
iface bond0 inet static
address 192.168.1.5
netmask 255.255.0.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8
#bond-mode 0
#bond-miimon 100
up ifenslave bond0 em2 em5
down ifenslave -d bond0 em2 em5
cat /proc/net/bonding/bond0
提示up即成功:
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: *:*:*:*:*:*
Slave queue ID: 0
Slave Interface: em5
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: *:*:*:*:*:*
Slave queue ID: 0
而down表示未启用可能没有auto(自动
启用),可以尝试手工启动:
ifconfig bond0 up
Ubuntu server 14.04 LTS 多网卡绑定实现负载均衡
原文地址:http://blog.csdn.net/setoy/article/details/46648963