Solaris操作系统的网卡绑定是需要购买sun的Trunking软件的。 本文介绍的是Solaris自带的一个叫IPMP(IP网络多路径(IP Network Multipathing))。
8.测试
使用如下命令强行使网卡切换
#if_mpadm -d pcn2
下重新启用网卡
#if_mpadm -r pcn2
可以观察到网卡地址的切换,现象如下:
root:/#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
vmxnet0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.1.1.200 netmask ffffff00 broadcast 192.1.1.255
groupname fzu1
ether 0:c:29:b3:21:d3
vmxnet0:1: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 2
inet 192.1.1.201 netmask ffffff00 broadcast 192.1.1.255
vmxnet1: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 3
inet 192.1.1.202 netmask ffffff00 broadcast 192.1.1.255
groupname fzu1
ether 0:c:29:b3:21:dd
root:/#if_mpadm -d vmxnet0
root:/#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
vmxnet0: flags=89000842<BROADCAST,RUNNING,MULTICAST,IPv4,NOFAILOVER,OFFLINE> mtu 0 index 2
inet 0.0.0.0 netmask 0
groupname fzu1
ether 0:c:29:b3:21:d3
vmxnet1: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 3
inet 192.1.1.202 netmask ffffff00 broadcast 192.1.1.255
groupname fzu1
ether 0:c:29:b3:21:dd
vmxnet1:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 192.1.1.200 netmask ffffff00 broadcast 192.1.1.255
vmxnet1:2: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 3
inet 192.1.1.201 netmask ffffff00 broadcast 192.1.1.255
root:/#if_mpadm -r vmxnet0
root:/#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
vmxnet0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.1.1.200 netmask ffffff00 broadcast 192.1.1.255
groupname fzu1
ether 0:c:29:b3:21:d3
vmxnet0:1: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 2
inet 192.1.1.201 netmask ffffff00 broadcast 192.1.1.255
vmxnet1: flags=1040842<BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4> mtu 1500 index 3
inet 192.1.1.202 netmask ffffff00 broadcast 192.1.1.255
groupname fzu1
ether 0:c:29:b3:21:dd
solaris 双网卡绑定1.查看物理网卡
首先查看系统中有多少块物理网卡,执行以下命令:
dladm show-link
bge0 type: non-vlan mtu: 1500 device: bge0
bge1 type: non-vlan mtu: 1500 device: bge1
bge2 type: non-vlan mtu: 1500 device: bge2
bge3 type: non-vlan mtu: 1500 device: bge3
2.查看正在使用网卡
然后查看有哪些网卡正在使用:ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
bge0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 59.37.54.108 netmask ffffffe0 broadcast 59.37.54.127
ether 0:14:4f:2c:b3:90
bge1: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 0.0.0.0 netmask 0
ether 0:14:4f:2c:b3:91
bge2: flags=1000802<BROADCAST,MULTICAST,IPv4> mtu 1500 index 4
inet 0.0.0.0 netmask 0
ether 0:14:4f:2c:b3:92
3.停止需要绑定的网卡
看看是哪两个网卡要做绑定,先把他们停止
ifconfig bge1 unplumb
ifconfig bge2 unplumb
4.创建聚合链路
使用dladm创建聚合链路的虚拟网卡:
dladm create-aggr -d bge1 -d bge2 1
dladm的命令语法如下:
dladm create-aggr -d interface -d interface [...] key
interface 表示要成为聚合一部分的接口的设备名称。
key 是标识聚合的编号。最小的密钥编号是1。不允许将零用作密钥。
5.配置IP信息
为刚配置好的虚拟网卡配置IP,如:
ifconfig aggr1 plumb 192.168.84.14 up
6.检查刚创建的聚合的状态
# dladm show-aggr
如果希望虚拟网卡的配置在系统重启之后仍然可以使用,则需要创建一个/etc/hostname.aggr1文件,文件内容为IP地址,总之,这个aggr1的网卡可以像普通网卡一样配置IP地址。