單網卡多IP,多網卡綁定ip

單網卡綁定多個IP.

cd /etc/sysconfig/network-scripts/

根據需求創建多個IP文件(ifcfg-eth0:0ifcfg-eth01…..,ifcfg-eth0:X

cp ifcfg-eth0 ifcfg-eth0:0

cp ifcfg-eth0 ifcfg-eth0:1

cp ifcfg-eth0 ifcfg-eth0:X

 

修改新建文件的相關位置

DEVICE 設備名,是否靜態指定,和添加的IP地址)

[root@centosbenson network-scripts]# cat ifcfg-eth0:0

DEVICE=eth0:0

NM_CONTROLLED=yes    #是否被 networkmanager(圖形管理工具)的服務控制

BOOTPROTO=static

TYPE=Ethernet

USERCTL=no  #是否允許非root控制改設備

IPV6INIT=no

IPADDR=192.168.64.126

NETMASK=255.255.255.0

GATEWAY=192.168.64.2

DNS1=192.168.64.2

如圖

 

雙網卡綁定IP

網卡綁定技術有助於保證高可用性特性並提供其它優勢以提高網絡性能。

1.       創建虛擬網絡接口配置文件

cp ifcfg-eth0 ifcfg-bond0

####vim ifcfg-bond0,把改刪除的刪除掉,修改該修改滴。

[root@localhost network-scripts]# more ifcfg-bond0

DEVICE=bond0

BOOTPROTO=none

ONBOOT=yes

NETMASK=255.255.255.0

IPADDR=192.168.64.131

GATEWAY=192.168.64.2

TYPE=BOND

USERCTL=no

BONDING_OPTS="mode=1 miimon=100"

 

2.       修改ifcfg-eth0ifcfg-eth1

[root@localhost network-scripts]# more ifcfg-eth0

DEVICE=eth0

BOOTPROTO=none

ONBOOT=yes

TYPE=Ethernet

MASTER=bond0

slave=yes

USERCTL=no

[root@localhost network-scripts]# more ifcfg-eth1

DEVICE=eth1

BOOTPROTO=none

ONBOOT=yes

MASTER=bond0

slave=yes

USERCTL=no

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
表示負載均衡方式,兩塊網卡都工作,不需要交換機作支持

[root@localhost network-scripts]# more /etc/modprobe.conf

alias scsi_hostadapter mptbase

alias scsi_hostadapter1 mptspi

alias scsi_hostadapter2 ata_piix

alias snd-card-0 snd-ens1371

options snd-card-0 index=0

options snd-ens1371 index=0

remove snd-ens1371 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-ens1371

alias eth0 pcnet32

alias eth1 pcnet32

alias bond0 bonding

options bond0 miimon=100 mode=1

4.       /etc/rc.d/rc.local 加入如下一行

[root@localhost network-scripts]# more /etc/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

 

5.       service network restart或者reboot

 

6.       查看情況/proc/net/bonding/bond0

 

Ifconfig –a

 

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章