歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Centos6.5多網卡綁定

通過網口綁定(bond)技術,可以很容易實現網口冗余,負載均衡,從而達到高可用負載均衡的目的。

[root@localhost ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

[root@localhost ~]# echo "alias netdev-bond0 bonding" >/etc/modprobe.d/bonding.conf

網卡綁定前需要執行這個命令,以此來添加服務器啟動時加載的模塊。

修改新建網卡綁定bond0配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
USERCTL=no
PEERDNS=yes
IPV6INIT=no
IPADDR=112.25.xx.xx
NETMASK=255.255.255.192
BROADCAST=112.25.xx.xx
GATEWAY=112.25.xx.xx
BONDING_OPTS="miimon=80 mode=6"

miimon 是鏈路監測的時間間隔單位是毫秒,miimon=80的意思就是每80ms監測一次鏈路連接狀態,如果有一條線路不通就轉入另一條線路。

mode=0 表示負載均衡方式,兩塊網卡都工作,需要交換機作支持

mode=1 表示冗余方式,網卡只有一個工作,一個出問題啟用另外的

mode=6 表示負載均衡方式,兩塊網卡都工作,不需要交換機作支持

\

我這裡做的是四個網卡的綁定,服務器是dell R720,其網卡默認名稱為em1--em4,網卡綁定時候,四個網卡的配置基本相似,master需要制定為bond0,四個網卡均為slave

\

 

\

 

重啟服務器

然後查看網卡綁定信息

\

 

\

 

[root@localhost ~]# ifconfig
bond0 Link encap:Ethernet HWaddr F8:BC:12:38:BF:04
inet addr:112.25.xx.17 Bcast:112.25.xx.63 Mask:255.255.255.192
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:198948 errors:0 dropped:0 overruns:0 frame:0
TX packets:374418 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20792024 (19.8 MiB) TX bytes:29577760 (28.2 MiB)


em1 Link encap:Ethernet HWaddr F8:BC:12:38:BF:04
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:36838 errors:0 dropped:0 overruns:0 frame:0
TX packets:123885 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3250190 (3.0 MiB) TX bytes:12842300 (12.2 MiB)
Interrupt:35


em2 Link encap:Ethernet HWaddr F8:BC:12:38:BF:05
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:88178 errors:0 dropped:0 overruns:0 frame:0
TX packets:87303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11017650 (10.5 MiB) TX bytes:6243968 (5.9 MiB)
Interrupt:38


em3 Link encap:Ethernet HWaddr F8:BC:12:38:BF:06
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:37044 errors:0 dropped:0 overruns:0 frame:0
TX packets:81803 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3274966 (3.1 MiB) TX bytes:5272322 (5.0 MiB)
Interrupt:34


em4 Link encap:Ethernet HWaddr F8:BC:12:38:BF:07
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:36888 errors:0 dropped:0 overruns:0 frame:0
TX packets:81427 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3249218 (3.0 MiB) TX bytes:5219170 (4.9 MiB)
Interrupt:36


lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:99 (99.0 b) TX bytes:99 (99.0 b)

Copyright © Linux教程網 All Rights Reserved