Linux网卡绑定实现
NIC channel bonding allows multiple network cards to act as one, allowing increased bandwidth and redundancy. Let's assume we have two network interfaces ("eth0" and "eth1") and we want to bond them so they look like a single interface ("bond0"). Add the following line to the "/etc/modprobe.conf" file. ============================= alias bond0 bonding ============================= The files defining the regular and bonded interfaces are located in the "/etc/sysconfig/network-scripts" directory. Create a new file called "ifcfg-bond0" for the bonded interface with the following contents (adjust the network parameters as applicable). ============================= [root@rhel5 network-scripts]# cat ifcfg-bond0 # Intel Corporation 82540EM Gigabit Ethernet Controller DEVICE=bond0 BOOTPROTO=static ONBOOT=yes USERCTL=no IPADDR=192.168.99.131 NETMASK=255.255.255.0 BONDING_OPTS="mode=1 miimon=100" ============================= 说明:miimon是用来进行链路监测的。 比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。 mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。 mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份. bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用 Amend the existing "ifcfg-eth0" and "ifcfg-eth1" files, adding the "MASTER" and "SLAVE" parameters. The contents of these files should look like this. ============================= [root@rhel5 network-scripts]# cat ifcfg-eth0 # Intel Corporation 82540EM Gigabit Ethernet Controller DEVICE=eth0 BOOTPROTO=none USERCTL=no ONBOOT=yes MASTER=bond0 SLAVE=yes [root@rhel5 network-scripts]# cat ifcfg-eth1 # Intel Corporation 82540EM Gigabit Ethernet Controller DEVICE=eth1 BOOTPROTO=none ONBOOT=yes USERCTL=none MASTER=bond0 SLAVE=yes ============================= Restart the network service. ============================= # service network restart ============================= Once the bond is configured it acts like any other Ethernet device. For example, you can configure alias interfaces to handle multiple IP addresses, as shown below. Create the "ifcfg-bond0:1" and "ifcfg-bond0:2" files in the "/etc/sysconfig/network-scripts" directory with the following contents. ============================= # ifcfg-bond0:1 file contents DEVICE=bond0:1 BOOTPROTO=none ONBOOT=yes NETWORK=192.168.0.0 NETMASK=255.255.255.0 IPADDR=192.168.0.172 USERCTL=no BONDING_OPTS="mode=1 miimon=100" # ifcfg-bond0:2 file contents DEVICE=bond0:2 BOOTPROTO=none ONBOOT=yes NETWORK=192.168.0.0 NETMASK=255.255.255.0 IPADDR=192.168.0.173 USERCTL=no BONDING_OPTS="mode=1 miimon=100" ============================= Restart the network service for the changes to take effect. 通过查看bond0的工作状态查询能详细的掌握bonding的工作状态 [root@redflag bonding]# cat /proc/net/bonding/bond0 bonding.c:v2.4.1 (September 15, 2003) Bonding Mode: load balancing (round-robin) MII Status: up MII Polling Interval (ms): 0 Up Delay (ms): 0 Down Delay (ms): 0 Multicast Mode: all slaves Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:0e:7f:25:d9:8a Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:0e:7f:25:d9:8b
>更多相关文章
- 11-131分钟学会U盘启动安装Linux系统
- 11-13克隆MAC地址来绕过强制门户
- 11-13Linux运维常见故障及处理的 32 个锦囊妙计
- 11-13如何快速以管理员权限运行Linux命令?
- 11-13超全面的Linux应急响应技巧
- 11-136 款面向 Linux 用户的开源绘图应用程序
首页推荐
佛山市东联科技有限公司一直秉承“一切以用户价值为依归
- 01-11全球最受赞誉公司揭晓:苹果连续九年第一
- 12-09罗伯特·莫里斯:让黑客真正变黑
- 12-09谁闯入了中国网络?揭秘美国绝密黑客小组TA
- 12-09警示:iOS6 惊现“闪退”BUG
- 12-25优酷推出U镜到底等直播功能 已应用在羽毛球
- 12-25百川智能正式发布全链路领域增强大模型
- 12-25SHEIN4家仓储物流园获“零废工厂”认证
- 12-25西方博主在TikTok上展现中国风貌,“China
- 12-05亚马逊推出新一代基础模型 任意模态生成大模
相关文章
24小时热门资讯
24小时回复排行
热门推荐
最新资讯
操作系统
黑客防御