centos 多网卡绑定实验

本文介绍如何在Linux系统中配置网卡绑定以实现负载均衡和冗余功能。具体步骤包括编辑modprobe.conf文件以启用网卡绑定模块,创建并设置ifcfg-bond0文件指定绑定模式及参数,调整ifcfg-eth0和ifcfg-eth1文件以作为从属设备,最后重启网络服务确保配置生效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. ) #vi  /etc/modprobe.conf 

后添加

alias bond0 bonding

options bonding max_bonds=1


2. ) # vi ifcfg-bond0 
加入如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.100.255
IPADDR=192.168.100.12
NETMASK=255.255.255.0
NETWORK=192.168.100.0
ONBOOT=yes

BONDING_OPTS="mode=1 miimon=100 primary=eth0"

3.) 修改ifcfg-eth0 ifcfg-eth1
# vi ifcfg-eth0
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
# cp ifcfg-eth0 ifcfg-eth1
# vi ifcfg-eth1
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes

4. )重启服务
# service network restart
查看一下

[root@localhost ~]# ifconfig -a

bond0     Link encap:Ethernet  HWaddr 00:0C:29:27:C3:F3  

          inet addr:192.168.100.141  Bcast:192.168.100.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe27:c3f3/64 Scope:Link

          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

          RX packets:9024 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1518 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:929203 (907.4 KiB)  TX bytes:249989 (244.1 KiB)


eth0      Link encap:Ethernet  HWaddr 00:0C:29:27:C3:F3  

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

          RX packets:3572 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1429 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:376305 (367.4 KiB)  TX bytes:240448 (234.8 KiB)


eth1      Link encap:Ethernet  HWaddr 00:0C:29:27:C3:F3  

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

          RX packets:5457 errors:0 dropped:0 overruns:0 frame:0

          TX packets:102 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:553198 (540.2 KiB)  TX bytes:11527 (11.2 KiB)


或者

1. 新建ifcfg-bond0

[root@dex network-scripts]# cd /etc/sysconfig/network-scripts/ 
[root@dex network-scripts]# cp ifcfg-eth0 ifcfg-bond0 
[root@dex network-scripts]# vi ifcfg-bond0  
加入如下内容 
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) 
DEVICE=bond0 
BOOTPROTO=none 
BROADCAST=192.168.100.255 
IPADDR=192.168.100.12 
NETMASK=255.255.255.0 
NETWORK=192.168.100.0 
ONBOOT=yes 
2. 修改ifcfg-eth0 ifcfg-eth1 
[root@dex network-scripts]# vi ifcfg-eth0 
修改为如下内容 
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) 
DEVICE=eth0 
BOOTPROTO=none 
ONBOOT=yes 
MASTER=bond0 
SLAVE=yes 
[root@dex network-scripts]# cp ifcfg-eth0 ifcfg-eth1 
[root@dex network-scripts]# vi ifcfg-eth1 
修改为如下内容 
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) 
DEVICE=eth0 
BOOTPROTO=none 
ONBOOT=yes 
MASTER=bond0 
SLAVE=yes 
3. 修改/etc/modprobe.conf文件 
[root@dex network-scripts]# vi /etc/modprobe.conf 
加入如下两行 
alias bond0 bonding 
options bond0 miimon=100 mode=1 
 
 
 
 
mode=0 表示两块网卡同时工作,提供负载均衡 
mode=1 表示提供冗余功能(主备模式)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值