Linux网卡切换测试

来源:互联网 发布:在线数据库设计 编辑:程序博客网 时间:2024/05/29 18:27
--登录Linux
--进入/etc/sysconfig/network-scripts/目录
[root@test] cd /etc/sysconfig/network-scripts/
[root@test network-scripts]# ls
ifcfg-bond0  ifcfg-eth3   ifdown-eth   ifdown-post    ifdown-tunnel  ifup-eth   ifup-plip   ifup-routes    init.ipv6-global
ifcfg-eth0   ifcfg-lo     ifdown-ippp  ifdown-ppp     ifup           ifup-ippp  ifup-plusb  ifup-sit       net.hotplug
ifcfg-eth1   ifdown       ifdown-ipv6  ifdown-routes  ifup-aliases   ifup-ipv6  ifup-post   ifup-tunnel    network-functions
ifcfg-eth2   ifdown-bnep  ifdown-isdn  ifdown-sit     ifup-bnep      ifup-isdn  ifup-ppp    ifup-wireless  network-functions-ipv6


--查看bond配置信息(可能有多个bond)
[root@test network-scripts]# more ifcfg-bond0
DEVICE=bond0
BONDING_OPTS="mode=1 miimon=100"
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR= xxxx
NETMASK= xxxx
GATEWAY= xxxx
IPV6INIT=no
USERCTL=no


--查看bond目前状态,当前状态是eth2是工作状态,eth1和2状态都是up
[root@test network-scripts]# more /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: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xxxx
Slave queue ID: 0


Slave Interface: eth2
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xxxx
Slave queue ID: 0


--将eth2 down掉,再查看bond状态,eth1变成工作状态,eth2状态变成down状态
[root@test network-scripts]# ifconfig eth2 down
[root@test network-scripts]# more /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: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xxxx
Slave queue ID: 0


Slave Interface: eth2
MII Status: down
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0


--将eth2启动,查看bond信息,eth1还是工作状态,eth2恢复up状态
[root@test network-scripts]# ifconfig eth2 up
[root@test network-scripts]# more /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: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xxxx
Slave queue ID: 0


Slave Interface: eth2
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0


--同理,关闭eth1,查看bond状态
[root@test network-scripts]# ifconfig eth1 down
[root@test network-scripts]# more /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: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: down
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0


Slave Interface: eth2
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0


--启动eth1,查看bond状态(bond状态中eth1的状态有可能有延时,多试两次)
[root@test network-scripts]# ifconfig eth1 up
[root@test network-scripts]# more /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: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0


Slave Interface: eth2
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xxxx
Slave queue ID: 0
[root@test network-scripts]# 
0 0