A-A+

Cisco Packet Tracer 之 三层交换机使用路由协议实验

2016年01月05日 路由器高级应用 暂无评论 阅读 3 views 次

实验环境和实验目的:(两间公司之间的VLAN互通)

1、在B公司里配置三层交换机,把FA0/1 FA0/2 FA0/3 设置为TRUNK端口。

2、在B公司的三层交换机,创建VTP,并且创建VLAN20 VLAN30 VLAN40 VLAN100,并设置相应的IP地址。

3、在B公司的三层交换机,创建各VLAN的IP地址池。

4、在B公司的二层交换机,设置VTP CLIENT。

5、在B公司里,按图把各个PC加入到相应的VLAN口中,并查看是否可以获取IP地址。

6、在B公司的三层交换机里启用路由功能IP ROUTING,并测试公司内部各网段是否互通。

备注:以上步骤A公司的操作省略。

7、在两间公司的专线端口上关闭交换功能,并设置相应的IP地址。

8、先测试两公司之间的VLAN是否可互通。

9、因各VLAN不是直连,所以必须要在各公司的三层交换机添加相应的路由协议。

10、测试两个网段之间的PC是否可以互通。

实验步骤:

1、在B公司里配置三层交换机,把FA0/1 FA0/2 FA0/3 设置为TRUNK端口。

  1. CoreSWB(config)#int fa0/1  
  2. CoreSWB(config-if)#switchport trunk encapsulation dot1q   
  3. CoreSWB(config-if)#switchport mode trunk  
  4. CoreSWB(config)#int fa0/2  
  5. CoreSWB(config-if)#switchport trunk encapsulation dot1q  
  6. CoreSWB(config-if)#switchport mode trunk  
  7. CoreSWB(config)#int fa0/3  
  8. CoreSWB(config-if)#switchport trunk encapsulation dot1q  
  9. CoreSWB(config-if)#switchport mode trunk  

2、在B公司的三层交换机,创建VTP,并且创建VLAN20 VLAN30 VLAN40 VLAN100,并设置相应的IP地址。

  1. CoreSWB(vlan)#vtp domain senya  
  2. Changing VTP domain name from NULL to senya  
  3. CoreSWB(vlan)#vtp server  
  4. Device mode already VTP SERVER.  
  5. CoreSWB#conf t  
  6. Enter configuration commands, one per line.  End with CNTL/Z.  
  7. CoreSWB(config)#vlan 20  
  8. CoreSWB(config-vlan)#exit  
  9. CoreSWB(config)#vlan 30  
  10. CoreSWB(config-vlan)#exit  
  11. CoreSWB(config)#vlan 40  
  12. CoreSWB(config-vlan)#exit  
  13. CoreSWB(config)#vlan 100  
  14. CoreSWB(config-vlan)#exit  
  15. CoreSWB(config)#int vlan20  
  16. CoreSWB(config-if)#ip add 192.168.20.1 255.255.255.0  
  17. CoreSWB(config-if)#exit  
  18. CoreSWB(config)#int vlan30  
  19. CoreSWB(config-if)#ip add 192.168.30.1 255.255.255.0  
  20. CoreSWB(config-if)#exit  
  21. CoreSWB(config)#int vlan40  
  22. CoreSWB(config-if)#  
  23. %LINK-5-CHANGED: Interface Vlan40, changed state to up  
  24. %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan40, changed state to up  
  25. CoreSWB(config-if)#ip add 192.168.40.1 255.255.255.0  
  26. CoreSWB(config-if)#exit  
  27. CoreSWB(config-if)#exit  

3、在B公司的三层交换机,创建各VLAN的IP地址池。

  1. CoreSWB(config)#ip dhcp pool vlan20  
  2. CoreSWB(dhcp-config)#network 192.168.20.0 255.255.255.0  
  3. CoreSWB(dhcp-config)#default-router 192.168.20.1   
  4. CoreSWB(dhcp-config)#exit  
  5. CoreSWB(config)#ip dhcp pool vlan30  
  6. CoreSWB(dhcp-config)#network 192.168.30.0 255.255.255.0  
  7. CoreSWB(dhcp-config)#default-router 192.168.30.1   
  8. CoreSWB(dhcp-config)#exit  
  9. CoreSWB(config)#ip dhcp pool vlan40  
  10. CoreSWB(dhcp-config)#network 192.168.40.0 255.255.255.0  
  11. CoreSWB(dhcp-config)#default-router 192.168.40.1   
  12. CoreSWB(dhcp-config)#exit  

4、在B公司的二层交换机,设置VTP CLIENT。(只显示一个交换机的操作步骤)

  1. Switch#vlan database   
  2. % Warning: It is recommended to configure VLAN from config mode,  
  3.   as VLAN database mode is being deprecated. Please consult user  
  4.   documentation for configuring VTP/VLAN in config mode.  
  5. Switch(vlan)#vtp domain senya  
  6. Domain name already set to senya.  
  7. Switch(vlan)#vtp client  
  8. Setting device to VTP CLIENT mode.  
  9. Switch(vlan)#exit  
  10. APPLY completed.  
  11. Switch#show vlan  
  12. VLAN Name                             Status    Ports  
  13. ---- -------------------------------- --------- -------------------------------  
  14. 1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5  
  15.                                                 Fa0/6, Fa0/7, Fa0/8, Fa0/9  
  16.                                                 Fa0/10, Fa0/11, Fa0/12, Fa0/13  
  17.                                                 Fa0/14, Fa0/15, Fa0/16, Fa0/17  
  18.                                                 Fa0/18, Fa0/19, Fa0/20, Fa0/21  
  19.                                                 Fa0/22, Fa0/23, Fa0/24  
  20. 20   VLAN0020                         active      
  21. 30   VLAN0030                         active      
  22. 40   VLAN0040                         active      
  23. 100  VLAN0100                         active      
  24. 1002 fddi-default                     act/unsup   
  25. 1003 token-ring-default               act/unsup   
  26. 1004 fddinet-default                  act/unsup   
  27. 1005 trnet-default                    act/unsup   
  28. VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2  
  29. ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------  
  30. 1    enet  100001     1500  -      -      -        -    -        0      0  
  31. 20   enet  100020     1500  -      -      -        -    -        0      0  

5、在B公司里,按图把各个PC加入到相应的VLAN口中,并查看是否可以获取IP地址。(其它交换机操作省略)

  1. Switch#conf t  
  2. Enter configuration commands, one per line.  End with CNTL/Z.  
  3. Switch(config)#int fa0/2  
  4. Switch(config-if)#switchport mode access  
  5. Switch(config-if)#switchport access vlan 20  

6、在B公司的三层交换机里启用路由功能IP ROUTING,并测试公司内部各网段是否互通。

在没有IP ROUTING的情况下如下:

在三层交换机启用IP ROUTING后,如下:

7、在两间公司的专线端口上关闭交换功能,并设置相应的IP地址和测试是否能PING通。

  1. A公司:  
  2. CoreSW(config)#int fa0/4  
  3. CoreSW(config-if)#no switchport  
  4. CoreSW(config-if)#ip add 192.168.100.1 255.255.255.0  
  5. B公司:  
  6. CoreSWB(config)#int fa0/5  
  7. CoreSWB(config-if)#no switchport  
  8. CoreSWB(config-if)#ip add 192.168.100.2 255.255.255.0  

两公司之间互通:

  1. CoreSW#PING 192.168.100.2  
  2. Type escape sequence to abort.  
  3. Sending 5, 100-byte ICMP Echos to 192.168.100.2, timeout is 2 seconds:  
  4. !!!!!  
  5. Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms  

8、先测试两公司之间的VLAN是否可互通。

  1. CoreSW#show ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  7.        * - candidate default, U - per-user static route, o - ODR  
  8.        P - periodic downloaded static route  
  9. Gateway of last resort is not set  
  10. C    192.168.2.0/24 is directly connected, Vlan2  
  11. C    192.168.3.0/24 is directly connected, Vlan3  
  12. C    192.168.4.0/24 is directly connected, Vlan4  
  13. C    192.168.100.0/24 is directly connected, FastEthernet0/4  

9、因各VLAN不是直连,所以必须要在各公司的三层交换机添加相应的路由协议。

A公司添加B公司的VLAN网段信息如下:

  1. CoreSW#conf t  
  2. Enter configuration commands, one per line.  End with CNTL/Z.  
  3. CoreSW(config)#router rip  
  4. CoreSW(config-router)#ver 2  
  5. CoreSW(config-router)#no au  
  6. CoreSW(config-router)#net 192.168.2.0  
  7. CoreSW(config-router)#net 192.168.3.0  
  8. CoreSW(config-router)#net 192.168.4.0  
  9. CoreSW(config-router)#net 192.168.100.0  

B公司添加A公司的VLAN网段信息如下:

  1. CoreSWB#conf t  
  2. Enter configuration commands, one per line.  End with CNTL/Z.  
  3. CoreSWB(config)#router rip  
  4. CoreSWB(config-router)#ver 2  
  5. CoreSWB(config-router)#no au  
  6. CoreSWB(config-router)#net 192.168.20.0  
  7. CoreSWB(config-router)#net 192.168.30.0  
  8. CoreSWB(config-router)#net 192.168.40.0  
  9. CoreSWB(config-router)#net 192.168.100.0  

RIP协议是把自己本网段的VLAN宣告到别的交换机上。

A公司三层交换机的路由表情况:

  1. CoreSW#show ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  7.        * - candidate default, U - per-user static route, o - ODR  
  8.        P - periodic downloaded static route  
  9. Gateway of last resort is not set  
  10. C    192.168.2.0/24 is directly connected, Vlan2  
  11. C    192.168.3.0/24 is directly connected, Vlan3  
  12. C    192.168.4.0/24 is directly connected, Vlan4  
  13. R    192.168.20.0/24 [120/1] via 192.168.100.2, 00:00:25, FastEthernet0/4  
  14. R    192.168.30.0/24 [120/1] via 192.168.100.2, 00:00:25, FastEthernet0/4  
  15. R    192.168.40.0/24 [120/1] via 192.168.100.2, 00:00:25, FastEthernet0/4  
  16. C    192.168.100.0/24 is directly connected, FastEthernet0/4  

B公司的路由表情况如下:

  1. CoreSWB#  
  2. CoreSWB#show ip route  
  3. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  4.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  5.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  6.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  7.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  8.        * - candidate default, U - per-user static route, o - ODR  
  9.        P - periodic downloaded static route  
  10. Gateway of last resort is not set  
  11. R    192.168.2.0/24 [120/1] via 192.168.100.1, 00:00:10, FastEthernet0/4  
  12. R    192.168.3.0/24 [120/1] via 192.168.100.1, 00:00:10, FastEthernet0/4  
  13. R    192.168.4.0/24 [120/1] via 192.168.100.1, 00:00:10, FastEthernet0/4  
  14. C    192.168.20.0/24 is directly connected, Vlan20  
  15. C    192.168.30.0/24 is directly connected, Vlan30  
  16. C    192.168.40.0/24 is directly connected, Vlan40  
  17. C    192.168.100.0/24 is directly connected, FastEthernet0/4  

10、测试两个网段之间的PC是否可以互通。

标签:

给我留言