博客统计信息

51cto博客之星
用户名:hackerjx
文章数:61
评论数:538
访问量:357895
无忧币:2009
博客积分:3387
博客等级:7
注册日期:2008-05-18

配置多台三层交换VLAN间相互通信
2009-10-23 10:46:38
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://hackerjx.blog.51cto.com/383839/215389
本实验需求:
 通过在SW100 来创建VLAN 100 ,sw2 上创建VLAN 200,因为VLAN100和VLAN200因为业务上的关系,需要两台PC之间相互通信,保证不同VLAN之间可以互相访问。 本实验将给您详细阐述实现方法,将用到诸多交换知识点。

实验拓扑:
image
 
实验过程 第一步 SW100基础配置
SW100>
SW100>enable
SW100#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW100(config)#no ip do lo
SW100(config)#line con 0
SW100(config-line)#no exec-t
SW100(config-line)#logg syn
SW100(config-line)#exit
SW100(config)#username admin privilege 15 password admin
SW100(config)#line vty 0 15
SW100(config-line)#login local
SW100(config-line)#int f0/24
//配置把二层接口更改为三层接口
SW100(config-if)#no switchport
SW100(config-if)#ip add 12.0.0.1 255.255.255.0
00:02:57: %LINK-3-UPDOWN: Interface FastEthernet0/24, changed state to up
00:02:58: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up
SW100(config-if)#no sh
第二步 SW200 基础配置
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host SW200
SW200(config)#no ip do lo
SW200(config)#line con 0
SW200(config-line)#no exec-t
SW200(config-line)#logg syn
SW200(config-line)#exit
SW200(config)#username admin privilege 15 password admin
SW200(config)#line vty 0 15
SW200(config-line)#login local
SW200(config-line)#int f0/24
//把二层端口改变成三层接口
SW200(config-if)#no switchport
SW200(config-if)#ip add 12.0.0.2 255.2
00:03:40: %LINK-3-UPDOWN: Interface FastEthernet0/24, changed state to up
00:03:41: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up
SW200(config-if)#ip add 12.0.0.2 255.255.255.0
SW200(config-if)#no sh
SW200(config-if)#exit
第三步 完整SW1上VLAN配置
//创建VLAN 100
SW100(config)#vlan 100
//给VLAN命名为100
SW100(config-vlan)#name 100
//进入f0/13接口模式下,把f0/13接口划分到VLAN100
SW100(config-vlan)#int f0/13
SW100(config-if)#switchport mode access
SW100(config-if)#switchport access vlan 100
SW100(config-if)#exit
SW100(config)#int f0/13
//因为此接口连接的终端设备,故可以关闭生成树的选举,开启快速端口特性
SW100(config-if)#spanning-tree portfast
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/15 but will only
have effect when the interface is in a non-trunking mode.
SW100(config-if)#exit
00:05:40: %SYS-5-CONFIG_I: Configured from console by console
//查看VLAN信息
SW100#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/23, Gi0/1, Gi0/2
100 100 active Fa0/13
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
第四步 完成SW200上VLAN配置
SW200(config)#vlan 200
SW200(config-vlan)#name 200
SW200(config-vlan)#int f0/15
SW200(config-if)#switchport mode access
SW200(config-if)#switchport access vlan 200
SW200(config-if)#exit
SW200(config)#int f0/15
SW200(config-if)#spanning-tree portfast
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/15 but will only
have effect when the interface is in a non-trunking mode.
SW100#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/23, Gi0/1, Gi0/2
200 200 active Fa0/15
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
第五步 在SW100上创建SVI(交换虚拟接口),并给SW100所连接PC配置IP地址为192.168.0.100,网关192.168.0.1(PC配置IP地址,网关,实验手册内容略过)
SW100#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//进入VLAN 100
SW100(config)#int vlan 100
//配置VLAN100,IP地址,这里的IP地址,就是F0/13接口下PC所指的网关地址
SW100(config-if)#ip add 192.168.0.1 255.255.255.0
SW100(config-if)#no sh
SW100(config-if)#end
00:06:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up
//从SW100上测试可以ping通本VLAN下PC
SW100#ping 192.168.0.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.100, timeout is 2 seconds:
!!!!!
第六步 在SW200上创建SVI(交换机虚拟接口),并给SW200所连接PC配置IP地址为172.16.0.100,网关172.16.0.1(PC配置IP地址,实验手册内容略过)
SW200(config-if)#exit
SW200(config)#int vlan 200
SW200(config-if)#ip add 172.16.0.1 255.255.255.0
00:04:41: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up
SW200(config-if)#no sh
SW200(config-if)#end
00:04:52: %SYS-5-CONFIG_I: Configured from console by console
SW200#ping 172.16.0.200
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.200, timeout is 2 seconds:
!!!!!
第七步 在SW100 上开启路由功能,并运行动态路由协议
SW100#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//开启三层交换路由功能,默认是关闭的
SW100(config)#ip routing
SW100(config)#router ospf 100
SW100(config-router)#net 12.0.0.1 0.0.0.255 a 0
SW100(config-router)#net 192.168.0.1 0.0.0.255 a 0
SW100(config-router)#end
SW100#
00:08:11: %SYS-5-CONFIG_I: Configured from console by console


第八步 在SW200 上开启路由功能,并运行动态路由协议
SW200#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//注意:如果没有开启路由功能,直接运行路由协议,将提示如下的错误信息
SW200(config)#router ospf 200
IP routing not enabled
SW200(config)#ip routing
SW200(config)#router ospf 200
SW200(config-router)#net 12.0.0.2 0.0.0.255 a 0
SW200(config-router)#net 172.16.0.2 0.0.0.255 a 0
SW200(config-router)#end
00:05:27: %OSPF-5-ADJCHG: Process 200, Nbr 192.168.0.1 on FastEthernet0/24 from LOADING to FULL, Loading Done
//查看路由表,观察通过OSPF学习到路由条目
SW200#show ip ro
00:05:33: %SYS-5-CONFIG_I: Configured from console by console
SW200#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Vlan200
O 192.168.0.0/24 [110/2] via 12.0.0.1, 00:00:02, FastEthernet0/24
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, FastEthernet0/24
//测试IP连通性
SW200#ping 12.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
SW200#ping 192.168.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
SW200#ping 192.168.0.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
SW200#
第九步 在PC2 用ping命令测试到PC1,测试vlan200是否可以和VLAN 100 PING通,测试结果全网ping 通,实验现象成功(因为PC2是windows 7 简体中文版本,故ping结果是中文方式显示的) 测试步骤:开始-运行-cmd
C:\>ping 172.16.0.1
正在 Ping 172.16.0.1 具有 32 字节的数据:
来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255
来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255
来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255
来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255
172.16.0.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 1ms,最长 = 1ms,平均 = 1ms
Control-C
^C
C:\>ping 12.0.0.2
正在 Ping 12.0.0.2 具有 32 字节的数据:
来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255
来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255
来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255
来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255
12.0.0.2 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 2ms,最长 = 2ms,平均 = 2ms
Control-C
^C
C:\>ping 12.0.0.1
正在 Ping 12.0.0.1 具有 32 字节的数据:
来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254
12.0.0.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 1ms,最长 = 1ms,平均 = 1ms
Control-C
^C
C:\>ping 192.168.0.1
正在 Ping 192.168.0.1 具有 32 字节的数据:
来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254
来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254
192.168.0.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 1ms,最长 = 1ms,平均 = 1ms
Control-C
^C
C:\>ping 192.168.0.200
正在 Ping 192.168.0.200 具有 32 字节的数据:
Control-C
^C
C:\>ping 192.168.0.100
正在 Ping 192.168.0.100 具有 32 字节的数据:
来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62
来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62
来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62
来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62
192.168.0.100 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 =4,丢失 = 0 (0% 丢失)
往返行程的估计时间(以毫秒为单位):
最短 = 1ms,最长 = 1ms,平均 = 1ms
Control-C
^C

本文出自 “王万利的博客” 博客,请务必保留此出处http://hackerjx.blog.51cto.com/383839/215389

分享至
更多
一键收藏,随时查看,分享好友!
yu344109534、kk876435928
2人
了这篇文章
类别:Cisco技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

文章评论

 
2009-11-03 11:17:02
有个问题,你在SW100上宣告OSPF,SW200还没宣告OSPF的时候,怎么可能SH IP ROUTE 就可以找到SW2上172的网段了??你顺序贴错了吧
博主回复:
2009-11-03 11:30:24
你好,yif417看的很细心。谢谢
你说的没错,如果只在一台交三层换机上启用了OSPF,另外一台三层交换还没开启OSPF,没有OSPF的的hello,没有邻居,自然没有路由。
这个步骤我会改一下。
照我我的配置做下来,路由表肯定是有的,而且现象是完全相同的。

2009-11-03 21:49:46
好久没做实验了,做这个都花了1个小时!还是那个第一台三层交换机没开路由,我说怎么总是PING不通!找了好久才找到错误!

2009-11-03 21:57:15
你好, dysfgjl1987
多练习,你能保证每天完成一篇实验,坚持下来,不可估量。
随时有问题来我博客提问,尽最大的能力帮助大家。
关于本实验你想到通过其他方式来实现吗?
两台三层交换之间,不开启路由协议,能实现VLAN间相互通信吗?

2009-11-13 14:19:33
呵呵。楼主辛苦,学习了。
博主回复:
2009-11-13 23:04:21
朋友客气了,能帮助大家也是件开心的事情。

2009-11-17 16:16:00
我把sw100的f0/1 和 sw200的 f0/1分别加入vlan 200 然后在sw100上 给int 200地址 开启ip routing 把pc2的网关指向sw100上的int vlan200地址 这样两台pc就可以互通了 不知道我的想法对不对 如果有问题 请博主指点

2009-11-29 11:09:12
两台三层交换机A与B之间的用两条链路连接,3层交换机A下连接一个vlan40,3层交换机B下连接个2层的交换机,2层的交换机有两个vlan,分别是vlan20和30。要在其配置生成树协议STP,模式为RSTP。VLAN20和VLAN30分别通过不同的链路实现通信。请问下吗,要怎么配置呢?我做了很久也找了很多资料都做不成,还望高手不吝赐教!!!
博主回复:
2009-12-01 15:53:01
VLAN 20 和VLAN30 处在二层交换机上,要想本二层交换机做这个VLAN之间相互通信,没办法实现。可是你的3层交换机B下连接的2层交换机,可以此三层交换机连接二层交换机的接口下,no switchport ,把二层的接口变成3层,配置子接口,二层交换机做Trunk ,可以实现VLAN 20 和VLAN 30 相互通信。
实际上就是单臂路由,注意子接口封装形式。

另外种方法就是: 在3层交换机B 上起两个SVI接口,
int vlan 20
ip ad X.X.X.X 255.255.255.0
int vlan 30
ip add x.x.xx. 255.255.255.0

2011-09-29 17:11:16
做好二次才成功,感觉之前学的全忘记了。谢谢楼主分享这么详细的资料。希望楼主尽快更新更新下,在等待中········

2011-10-12 23:13:31
你好,不同vlan通过同一根线路不是要设置trunk吗,你的实验照着做了可以通信,但是还是有些不理解,我们老师之前做这个不仅设置了trunk,还做了路由协议的配置,是不是这个实验有好几种方法啊?

 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: