Linux别名和多网卡绑定


一.Linux别名(单网卡多个IP地址)

1.修改配置文件

vim /etc/sysconfig/network-scripts/eth0:0

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.2.112
PREFIX=24
GATEWAY=192.168.2.1
DNS1=192.168.1.1
dns2=192.168.2.1
ONPARENT='yes‘

2.重新启动网卡

/etc/init.d/network restart
3.down掉eth0:0

ifdown eth0:0

二.多网卡绑定(多个网卡绑定同一个IP,增加网络冗余)

1.配置bond0网卡

vim ifcfg-bond0

DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.2.109
PREFIX=24
GATEWAY=192.168.2.1
DNS1=192.168.1.1
dns2=192.168.2.1
BONDING_OPTS="mode=1 miimon=50"

2.配置eth0网卡

vim ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER="bond0"
SLAVE=yes

3.配置eth1网卡

vim ifcfg-eth1

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER="bond0"
SLAVE=yes
4.重新启动网卡

/etc/init.d/network restart

5.配置系统加载binding模块:

vim /etc/modprobe.d/bonding.conf

alias bond0 bonding

6.监控设备bond0的状况

watch cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 50
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:21:c0:09
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:14:10:10
Slave queue ID: 0

可以看到两块绑定的网卡,状态显示正常

7.ifdown eth0

down掉eth0网卡,再监控bond0,可以发现只剩下eth1网卡工作了


very 2.0s: cat /proc/net/bonding/bond0                 Mon Jan 26 15:04:56 2015

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 50
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:14:10:10
Slave queue ID: 0

你可能感兴趣的:(Linux别名和多网卡绑定)