Linux双网卡绑定
作者:Eric
微信:loveoracle11g
eth0和eth1绑定为bond0
[root@rac-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
DEVICE=eth0
MASTER=bond0
SLAVE=yes [root@rac-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
DEVICE=eth1
MASTER=bond0
SLAVE=yes [root@rac-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
DEVICE=bond0
IPADDR=192.168.56.11
NETMASK=255.255.255.0
GATEWAY=192.168.56.2
NM_CONTROLLED=no 使用Vim文本编辑器创建一个用于网卡绑定的驱动文件,使得绑定后的bond0网卡设备能够支持绑定技术(bonding);同时定义网卡以mode6模式进行绑定,且出现故障时自动切换的时间为100毫秒。
常见的网卡绑定驱动有三种模式—mode0、mode1和mode6。下面以绑定两块网卡为例,讲解使用的情景。
mode0(平衡负载模式):平时两块网卡均工作,且自动备援,但需要在与服务器本地网卡相连的交换机设备上进行端口聚合来支持绑定技术。
mode1(自动备援模式):平时只有一块网卡工作,在它故障后自动替换为另外的网卡。
mode6(平衡负载模式):平时两块网卡均工作,且自动备援,无须交换机设备提供辅助支持。 [root@rac-node1 ~]# cat /etc/modprobe.d/bond.conf
alias bond0 bonding
options bond0 miimon=100 mode=6 [root@rac-node1 ~]# /etc/init.d/network restart
Shutting down interface eth0: /etc/sysconfig/network-scripts/ifdown-eth: line 124: /sys/class/net/bond0/bonding/slaves: No such file or directory
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface bond0: Determining if ip address 192.168.10.11 is already in use for device bond0...
[ OK ] [root@rac-node1 ~]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0C:29:FD:2F:24
inet 192.168.56.11 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 addr: fe80::20c:29ff:fefd:2f24/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1522 (1.4 KiB) TX bytes:2746 (2.6 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:FD:2F:24
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:2420 errors:0 dropped:0 overruns:0 frame:0
TX packets:2034 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:227710 (222.3 KiB) TX bytes:298140 (291.1 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:FD:2F:2E
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:360 (360.0 b) TX bytes:592 (592.0 b) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:118 errors:0 dropped:0 overruns:0 frame:0
TX packets:118 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10116 (9.8 KiB) TX bytes:10116 (9.8 KiB) [root@rac-node1 ~]# /etc/init.d/network restart
Shutting down interface bond0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface bond0: Determining if ip address 192.168.56.11 is already in use for device bond0...
[ OK ]