CentOS网卡设置 CentOS6.2网卡设置
人气:0下面主要介绍在CentOS6.2下使用系统自带的bonding进行网卡绑定的详细步骤。
注意:请在配置前关闭NetworkManager服务
[root@h63 ~]# service NetworkManager status && service NetworkManager start
网卡绑定一次可以绑定多个网卡,你可以使用ifconfig -a查看你的网卡信息,例如:
[root@h63 ~]# ifconfig -a
em1 Link encap:Ethernet HWaddr 78:2B:CB:30:08:03
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:48236002 errors:0 dropped:0 overruns:0 frame:0
TX packets:16156472 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4838973371 (4.5 GiB) TX bytes:1301118550 (1.2 GiB)
Interrupt:36 Memory:d6000000-d6012800
em2 Link encap:Ethernet HWaddr 78:2B:CB:30:08:05
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:42385720 errors:0 dropped:0 overruns:0 frame:0
TX packets:7283526 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4307780986 (4.0 GiB) TX bytes:466840625 (445.2 MiB)
Interrupt:48 Memory:d8000000-d8012800
em3 Link encap:Ethernet HWaddr 78:2B:CB:30:08:07
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:32 Memory:da000000-da012800
em4 Link encap:Ethernet HWaddr 78:2B:CB:30:08:09
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:42 Memory:dc000000-dc012800
这里有4个网卡,分别是em1、em2、em3和em4,我们把em1和em2做一个绑定,绑定模式为6(关于网卡绑定模式的介绍请看Linux网卡绑定探析),首先我给给网卡绑定后的设备起个名字bond0(名称可以自定义),并创建:
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 #设备名称
BOOTPROTO=static #静态IP
ONBOOT=yes #自动启动
IPADDR=172.16.16.63 #设备绑定的IP
GATEWAY=172.16.23.254 #设备绑定的网关
NETMASK=255.255.248.0 #设备绑定的掩码
TYPE=Ethernet #设备绑定的类型
编辑需要绑定的网卡:
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0 #绑定后的设备名称
SLAVE=yes
TYPE=Ethernet
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0 #绑定后的设备名称
SLAVE=yes
TYPE=Ethernet
说明:配置网卡时不要填写IP地址和MAC地址
配置加载模式设置:
[root@h63 ~]# vim /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=6
说明:mode是网卡绑定的模式,此处是模式6
也可以在/etc/modprobe.d/下创建一个文件:
[root@h63 ~]# vim /etc/modprobe.d/bond
alias bond0 bonding
options bond0 miimon=100 mode=6
绑定配置完成,重启网络服务
[root@h63 ~]#service network restart
查看网卡绑定的情况:
[root@h63 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: em1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 78:2b:cb:30:08:03
Slave queue ID: 0
Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 78:2b:cb:30:08:05
Slave queue ID: 0
至此,网卡绑定就完成了。有不对的地方,还请指教。
加载全部内容