目标:多网卡虚拟一个网卡,使其一网卡坏掉不影响网络使用。
步骤:
1、修改eth0、eth1配置文件
ifcfg-eth0
 
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
 
ifcfg-eth1
 
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
2、配置虚拟网卡
vi /etc/sysconfig/network-scripts/ifcfg-bond0
 
DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.1.255
IPADDR=192.168.1.97
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.1.1
USERCTL=no
 
3、编辑modules.conf
vi /etc/modules.conf
alias bond0 bonding
options bond0 miimon=100 mode=1 primary=eth0
4、添加rc.local
modprobe bonding miimon=100 mode=1
 
ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0C:29:20:C9:4A 
          inet addr:192.168.1.97  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:1065 errors:0 dropped:0 overruns:0 frame:0
          TX packets:694 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:102157 (99.7 KiB)  TX bytes:104152 (101.7 KiB)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:20:C9:4A 
          inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:981 errors:0 dropped:0 overruns:0 frame:0
          TX packets:697 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:90816 (88.6 KiB)  TX bytes:105086 (102.6 KiB)
          Interrupt:185 Base address:0x1400
eth1      Link encap:Ethernet  HWaddr 00:0C:29:20:C9:4A 
          inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:89 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11641 (11.3 KiB)  TX bytes:468 (468.0 b)
          Interrupt:169 Base address:0x1480