单网卡绑定多个IP.
cd /etc/sysconfig/network-scripts/
根据需求创建多个IP文件(ifcfg-eth0:0,ifcfg-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-eth0和ifcfg-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
查看情况 /proc/net/bonding/bond0Ifconfig �Ca