哎,这个做的可真是艰辛。昨天弄了一晚上,终于ping通了。今天早上还让一场大暴雨拍了个结实,万幸的是碰到了同学,蹭伞过来的,不过也基本上湿透了
闲话少说。昨天有人问,为什么只通过交换机可以实现三层交换?其实,核心交换机有路由器的功能,需要开启:ip routing。另外,在核心交换机与交换机之间有用到VTP技术。VTP(VLAN Trunking Protocol)是VLAN中继协议,也被称为虚拟局域网干道协议。它是思科私有协议。作用是十几台交换机在企业网中,配置VLAN工作量大,可以使用VTP协议,把一台交换机配置成VTP Server, 其余交换机配置成VTP Client,这样他们可以自动学习到server 上的VLAN 信息。
完成图:
1、先在核心交换机上设置好Trank,然后与接入交换机相连,接入交换机也为Trank。然后对核心交换机进行ip、vtp设置。
Switch(config)#int vlan 1
Switch(config-if)#ip address 10.0.0.1 255.0.0.0
Switch(config-if)#no shutSwitch(config-if)#end
Switch#vlan database
Switch(vlan)#vtp domain test
Changing VTP domain name from NULL to test
Switch(vlan)#vtp server
Device mode already VTP SERVER.
Switch(vlan)#vtp password test
Setting device VLAN database password to test
Switch(vlan)#vlan 2 name haha
Switch(vlan)#vlan 3 name heihei
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#show vlanVLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24, Gig0/1
Gig0/2
2 haha active
3 heihei active
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup..............................................................................
Switch#show vtp status
VTP Version : 2
Configuration Revision : 3
Maximum VLANs supported locally : 1005
Number of existing VLANs : 7
VTP Operating Mode : Server
VTP Domain Name : test
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0xB4 0x59 0xA2 0x7C 0x85 0x00 0x65 0x13
Configuration last modified by 10.0.0.1 at 3-1-93 00:26:16
Local updater ID is 10.0.0.1 on interface Vl1 (lowest numbered VLAN interface found)
2、对接入交换机进行设置:vlan 1连接核心交换机;vlan2、vlan3分别连两台电脑;
Switch(config)#int vlan 1
Switch(config-if)#ip address 10.0.0.2 255.255.255.0
Switch(config-if)#no shutSwitch(config-if)#end
Switch#ping 10.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 31/31/32 msSwitch#vlan database
Switch(vlan)#vtp domain test
Domain name already set to test.
Switch(vlan)#vtp client
Setting device to VTP CLIENT mode. .......................................................................这句很重要
Switch(vlan)#vtp pas
Switch(vlan)#vtp password test
Setting device VLAN database password to test
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch(config)#int f0/2
Switch(config-if)#switchport access vlan 2 ........................添加此句可以对交换机上的vlan设置ip
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#end
3、设置两台电脑与网关
ip:192.168.1.2 255.255.255.0 网关1192.168.1.1
ip:192.168.2.2 255.255.255.0 网关1192.168.2.1
并连接到接入交换机的相应接口上
4、对核心交换机进行vlan2、vlan3设置
Switch(config)#ip routing
Switch(config)#int vlan2
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(config)#int vlan 3Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit经测试两台电脑能互相通信。
最后解释一下ip routing 功能。有的高端交换机本身有路由功能模块,有的没有。对于再一个网络中有多个交换机的情况下,选择一个核心交换机应用路由功能,其他的关闭这个功能可以大大的减少网络阻塞的现象。默认ip routing 是打开的,关闭的命令是no ip routing。