xml地图|网站地图|网站标签 [设为首页] [加入收藏]

热门直播

当前位置:美高梅游戏网站 > 热门直播 > CentOS6.5双网卡绑定

CentOS6.5双网卡绑定

来源:http://www.gd-chuangmei.com 作者:美高梅游戏网站 时间:2019-09-04 01:23

网卡绑定就是多张网卡逻辑上作为一张网卡用。可分为,负载均衡绑定和冗余绑定两种。

一定要在服务管理中关闭NetworkManager服务并禁用自动启动。

1.编辑虚拟网络接口配置文件

[[email protected]~]# more /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=172.16.4.100
NETMASK=255.255.255.0
BROADCAST=172.16.4.255
NETWORK=172.168.4.100
ONBOOT=yes

第一步:先查看下本机网卡,使用命令到network-scripts下

2.编辑各网卡的配置文件,注意编辑之前做好备份工作

[[email protected]~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
MASTER=bond0
slave=yes
[[email protected] ~]# more /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
slave=yes

[[email protected]~]#cd/etc/sysconfig/network-scripts/

3.修改/etc/modprobe.conf 文件,同样做好备份,最后加入2行 alias bond0 bonding options bond0 miimon=100 mode=1 注: (1)、miimon 是链路监测的时间间隔单位是毫秒,miimon=100的意思就是,每100毫秒检测网卡和交换机之间是否连通,如不通则使用另外的链路。 (2)、mode=0 表示负载均衡方式,两块网卡都工作,需要交换机作支持 mode=1 表示冗余方式,网卡只有一个工作,一个出问题启用另外的 mode=6 表示负载均衡方式,两块网卡都工作,不需要交换机作支持

[[email protected]~]# more /etc/modprobe.conf
alias eth0 b44
alias eth1 8139too
alias usb-controller ehci-hcd
alias usb-controller1 ohci-hcd
alias bond0 bonding
options bond0 miimon=100 mode=0

[[email protected]~]#ll

4.在/etc/rc.d/rc.local 加入如下一行 ifenslave bond0 eth0 eth1

[[email protected]~]# more /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
ifenslave bond0 eth0 eth1

total202

5.重新启动后负载平衡已经能正常工作,service network restart,

-rw-r--r--1rootroot212Mar1515:40ifcfg-eth0

6.查看bond0的工作状态

[[email protected]~]# more /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.1 (October 29, 2004)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:1b:b9:58:8b:b2

Slave Interface: eth1
MII Status: down
Link Failure Count: 0
Permanent HW addr: 00:07:40:6c:ac:c8

-rw-r--r--1rootroot212Mar1515:40ifcfg-eth1

7.查看经过绑定后的网卡工作情况

[[email protected] ~]# ifconfig -a
bond0 Link encap:Ethernet HWaddr00:1B:B9:58:8B:B2

inet addr:172.16.4.100 Bcast:172.16.4.255 Mask:255.255.255.0
inet6 addr:fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNINGMASTER MULTICAST MTU:1500 Metric:1
RX packets:744154errors:0 dropped:0 overruns:0 frame:0
TX packets:1866915errors:0 dropped:0 overruns:0 carrier:0
collisions:0txqueuelen:0
RX bytes:1099876146 (1.0GiB) TX bytes:121233595 (115.6 MiB)

eth0 Link encap:Ethernet HWaddr00:1B:B9:58:8B:B2
inet6 addr:fe80::21b:b9ff:fe58:8bb2/64 Scope:Link
UP BROADCAST RUNNINGSLAVE MULTICAST MTU:1500 Metric:1
RX packets:744154errors:0 dropped:0 overruns:0 frame:0
TX packets:1866905errors:0 dropped:0 overruns:0 carrier:0
collisions:0txqueuelen:1000
RX bytes:1099876146 (1.0GiB) TX bytes:121232839 (115.6 MiB)
Interrupt:9

eth1 Link encap:Ethernet HWaddr00:1B:B9:58:8B:B2
inet6 addr:fe80::21b:b9ff:fe58:8bb2/64 Scope:Link
UP BROADCAST SLAVEMULTICAST MTU:1500 Metric:1
RX packets:0 errors:0dropped:0 overruns:0 frame:0
TX packets:10 errors:0dropped:0 overruns:0 carrier:0
collisions:0txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:756 (756.0 b)
Interrupt:11 Baseaddress:0x1000

lo Link encap:Local Loopback
inetaddr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128Scope:Host
UP LOOPBACKRUNNING MTU:16436 Metric:1
RX packets:2129 errors:0dropped:0 overruns:0 frame:0
TX packets:2129 errors:0dropped:0 overruns:0 carrier:0
collisions:0txqueuelen:0
RX bytes:1998893 (1.9MiB) TX bytes:1998893 (1.9 MiB)

sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0dropped:0 overruns:0 frame:0
TX packets:0 errors:0dropped:0 overruns:0 carrier:0
collisions:0txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

附:
DEVICE=物理设备名
IPADDR=IP地址
NETMASK=掩码值
NETWORK=网络地址
BROADCAST=广播地址
GATEWAY=网关地址
ONBOOT=[yes|no](引导时是否激活设备)
USERCTL=[yes|no](非root用户是否可以控制该设备)
BOOTPROTO=[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议)
HWADDR = 你的MAC地址

1.编辑虚拟网络接口配置文件 [[email protected]~]# more /etc...

第二步:复制ifcfg-bond0或者自己创造一个都可以,下面我介绍复制的命令

[[email protected]]#cpifcfg-eth0ifcfg-bond0

复制好了查看一下

[[email protected]]#ll

total204

-rw-r--r--1rootroot212Mar2315.42ifcfg-bond0

-rw-r--r--1rootroot212Mar1515:40ifcfg-eth0

-rw-r--r--1rootroot212Mar1515:40ifcfg-eth1

第三步:编辑ifcfg-bond0、ifcfg-eth0、ifcfg-eth1把里面内容替换一下内容

[[email protected]]#vimifcfg-bond0//(IP、MASK、子网掩码按自己服务器的需求来)

BOOTPROTO=none

DEVICE=bond0

ONBOOT=yes

IPADDR=172.26.5.16

NETMASK=255.255.255.128

GATEWAY=172.26.5.126

USERCTL=no

TYPE=Ethernet

IPV6INIT=no

DNS1=172.26.1.1

[[email protected]]#vimifcfg-eth0

BOOTPROTO=none

DEVICE=eth0

ONBOOT=yes

MASTER=bond0

SLAVE=yes

USERCTL=no

TYPE=Ethernet

IPV6INIT=no

[[email protected]]#vimifcfg-eth1

BOOTPROTO=none

DEVICE=eth1

ONBOOT=yes

MASTER=bond0

SLAVE=yes

USERCTL=no

TYPE=Ethernet

IPV6INIT=no

第四步:模块加载

[[email protected]~]#cd/etc/modprobe.d/

切换到modprobe.d目录下

[[email protected]~modprobe.d]#vidist.conf

本文由美高梅游戏网站发布于热门直播,转载请注明出处:CentOS6.5双网卡绑定

关键词:

上一篇:CentOS下安装网卡驱动程序详解整理

下一篇:没有了