zoukankan      html  css  js  c++  java
  • Trunk 实现跨交换机 VLAN 通信

    GNS3图标

    当网络中有多台交换机时,位于不同交换机上的相同VLAN的主机之间时如何通信的呢?我们使用Trunk实现跨交换机VLAN通信。还有以太网通道的操作哦。


    实验拓扑

    拓扑1

    两台交换机直连,每台下面再连接两台VPC,划分VLAN,地址规划如下:

    名称 接口 VLAN 地址
    PC1 SW1-f1/0 vlan 10 192.168.10.10/24
    PC2 SW1-f1/1 vlan 20 192.168.10.20/24
    PC3 SW2-f1/0 vlan 10 192.168.10.30/24
    PC4 SW2-f1/1 vlan 20 192.168.10.40/24

    配置方法

    SW1(config)#interface fastEthernet 1/2
    SW1(config-if)#switchport mode trunk
    SW1(config-if)#switchport trunk encapsulation dot1q
    SW1(config-if)#end
    

    配置过程

    交换机划分 VLAN

    • SW1
    SW1#conf t
    SW1(config)#no ip routing
    SW1(config)#vlan 10,20
    SW1(config-vlan)#ex
    SW1(config)#int f1/0
    SW1(config-if)#sw m a
    SW1(config-if)#sw a v 10
    SW1(config-if)#ex
    SW1(config)#int f1/1
    SW1(config-if)#sw m a
    SW1(config-if)#sw a v 20
    SW1(config-if)#ex
    SW1(config)#do show vlan-sw b
    
    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -------------------------------
    1    default                          active    Fa1/2, Fa1/3, Fa1/4, Fa1/5
                                                    Fa1/6, Fa1/7, Fa1/8, Fa1/9
                                                    Fa1/10, Fa1/11, Fa1/12, Fa1/13
                                                    Fa1/14, Fa1/15
    10   VLAN0010                         active    Fa1/0
    20   VLAN0020                         active    Fa1/1
    1002 fddi-default                     act/unsup
    1003 token-ring-default               act/unsup
    1004 fddinet-default                  act/unsup
    1005 trnet-default                    act/unsup
    
    • SW2
    SW2#conf t
    SW2(config)#no ip routing
    SW2(config)#vlan 10,20
    SW2(config-vlan)#ex
    SW2(config)#int f1/0
    SW2(config-if)#sw m a
    SW2(config-if)#sw a v 10
    SW2(config-if)#ex
    SW2(config)#int f1/1
    SW2(config-if)#sw m a
    SW2(config-if)#sw a v 20
    SW2(config-if)#ex
    SW2(config)#do show vlan-sw b
    
    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -------------------------------
    1    default                          active    Fa1/2, Fa1/3, Fa1/4, Fa1/5
                                                    Fa1/6, Fa1/7, Fa1/8, Fa1/9
                                                    Fa1/10, Fa1/11, Fa1/12, Fa1/13
                                                    Fa1/14, Fa1/15
    10   VLAN0010                         active    Fa1/0
    20   VLAN0020                         active    Fa1/1
    1002 fddi-default                     act/unsup
    1003 token-ring-default               act/unsup
    1004 fddinet-default                  act/unsup
    1005 trnet-default                    act/unsup
    

    配置 Trunk

    • SW1
    SW1(config)#interface fastEthernet 1/2
    SW1(config-if)#switchport mode trunk
    SW1(config-if)#switchport trunk encapsulation dot1q
    SW1(config-if)#end
    
    • 查询验证
    SW1#show interfaces fastEthernet 1/2 switchport
    Name: Fa1/2
    Switchport: Enabled
    Administrative Mode: trunk
    Operational Mode: trunk
    Administrative Trunking Encapsulation: dot1q
    Operational Trunking Encapsulation: dot1q
    Negotiation of Trunking: Disabled
    Access Mode VLAN: 0 ((Inactive))
    Trunking Native Mode VLAN: 1 (default)
    Trunking VLANs Enabled: ALL
    Trunking VLANs Active: 1,10,20
    Protected: false
    Priority for untagged frames: 0
    Override vlan tag priority: FALSE
    Voice VLAN: none
    Appliance trust: none
    
    • SW2
    SW2(config)#int f1/2
    SW2(config-if)#sw m t
    SW2(config-if)#sw t e d
    SW2(config-if)#do show int f1/2 switchport
    Name: Fa1/2
    Switchport: Enabled
    Administrative Mode: trunk
    Operational Mode: trunk
    Administrative Trunking Encapsulation: dot1q
    Operational Trunking Encapsulation: dot1q
    Negotiation of Trunking: Disabled
    Access Mode VLAN: 0 ((Inactive))
    Trunking Native Mode VLAN: 1 (default)
    Trunking VLANs Enabled: ALL
    Trunking VLANs Active: 1,10,20
    Protected: false
    Priority for untagged frames: 0
    Override vlan tag priority: FALSE
    Voice VLAN: none
    Appliance trust: none
    

    PING 测试

    • PC1
    PC1> ip 192.168.10.10
    Checking for duplicate address...
    PC1 : 192.168.10.10 255.255.255.0
    
    PC1> ping 192.168.10.20
    host (192.168.10.20) not reachable
    
    PC1> ping 192.168.10.30
    84 bytes from 192.168.10.30 icmp_seq=1 ttl=64 time=1.876 ms
    84 bytes from 192.168.10.30 icmp_seq=2 ttl=64 time=1.853 ms
    84 bytes from 192.168.10.30 icmp_seq=3 ttl=64 time=1.992 ms
    84 bytes from 192.168.10.30 icmp_seq=4 ttl=64 time=0.000 ms
    84 bytes from 192.168.10.30 icmp_seq=5 ttl=64 time=1.853 ms
    
    PC1> ping 192.168.10.40
    host (192.168.10.40) not reachable
    

    PC1 PING PC3 抓包

    • SW1F1/0接口开启抓包

    1p3f10

    • SW1F1/2接口开启抓包

    1p3f12

    数据包在出交换机时被打上vlan 10的标签。

    • PC2
    PC2> ip 192.168.10.20
    Checking for duplicate address...
    PC1 : 192.168.10.20 255.255.255.0
    
    PC2> ping 192.168.10.10
    host (192.168.10.10) not reachable
    
    PC2> ping 192.168.10.30
    host (192.168.10.30) not reachable
    
    PC2> ping 192.168.10.40
    84 bytes from 192.168.10.40 icmp_seq=1 ttl=64 time=1.992 ms
    84 bytes from 192.168.10.40 icmp_seq=2 ttl=64 time=1.999 ms
    84 bytes from 192.168.10.40 icmp_seq=3 ttl=64 time=1.870 ms
    84 bytes from 192.168.10.40 icmp_seq=4 ttl=64 time=1.842 ms
    84 bytes from 192.168.10.40 icmp_seq=5 ttl=64 time=1.846 ms
    

    PC2 PING PC4 抓包

    • SW1F1/1接口开启抓包

    2p4f11

    • SW1F1/2接口开启抓包

    2p4f12

    数据包在出交换机时被打上vlan 20的标签。

    • PC3
    PC3> ip 192.168.10.30
    Checking for duplicate address...
    PC1 : 192.168.10.30 255.255.255.0
    
    PC3> ping 192.168.10.10
    84 bytes from 192.168.10.10 icmp_seq=1 ttl=64 time=1.878 ms
    84 bytes from 192.168.10.10 icmp_seq=2 ttl=64 time=1.849 ms
    84 bytes from 192.168.10.10 icmp_seq=3 ttl=64 time=1.840 ms
    84 bytes from 192.168.10.10 icmp_seq=4 ttl=64 time=1.842 ms
    84 bytes from 192.168.10.10 icmp_seq=5 ttl=64 time=1.845 ms
    
    PC3> ping 192.168.10.20
    host (192.168.10.20) not reachable
    
    PC3> ping 192.168.10.40
    host (192.168.10.40) not reachable
    
    • PC4
    PC4> ip 192.168.10.40
    Checking for duplicate address...
    PC1 : 192.168.10.40 255.255.255.0
    
    PC4> ping 192.168.10.10
    host (192.168.10.10) not reachable
    
    PC4> ping 192.168.10.20
    84 bytes from 192.168.10.20 icmp_seq=1 ttl=64 time=1.962 ms
    84 bytes from 192.168.10.20 icmp_seq=2 ttl=64 time=1.994 ms
    84 bytes from 192.168.10.20 icmp_seq=3 ttl=64 time=1.981 ms
    84 bytes from 192.168.10.20 icmp_seq=4 ttl=64 time=1.991 ms
    84 bytes from 192.168.10.20 icmp_seq=5 ttl=64 time=1.965 ms
    
    PC4> ping 192.168.10.30
    host (192.168.10.30) not reachable
    

    以太网通道

    创建以太网通道可以增加链路的带宽,以及可靠性。


    拓扑图

    在当前实验的基础上,在交换机之间增加一条链路。

    拓扑2


    配置过程

    接口配成 Trunk

    • SW1
    SW1#conf t
    SW1(config)#int f1/3
    SW1(config-if)#sw m t
    SW1(config-if)#sw t e d
    SW1(config-if)#no sh
    
    • SW2
    SW2#conf t
    SW2(config)#int f1/3
    SW2(config-if)#sw m t
    SW2(config-if)#sw t e d
    SW2(config-if)#no sh
    

    接口绑定到一起

    • SW1
    SW1(config-if)#exit
    SW1(config)#int range fastEthernet 1/2 - 3
    SW1(config-if-range)#channel-group 1 mode on
    Creating a port-channel interface Port-channel1
    SW1(config-if-range)#
    *Mar  1 00:56:50.555: %EC-5-BUNDLE: Interface Fa1/2 joined port-channel Po1
    SW1(config-if-range)#
    *Mar  1 00:56:53.487: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
    
    • SW2
    SW2(config-if)#ex
    SW2(config)#int r f1/2 - 3
    SW2(config-if-range)#ch 1 m o
    Creating a port-channel interface Port-channel1
    SW2(config-if-range)#
    *Mar  1 01:00:16.955: %EC-5-BUNDLE: Interface Fa1/2 joined port-channel Po1
    SW2(config-if-range)#
    *Mar  1 01:00:19.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
    

    故障模拟

    验证以太网通道的可靠性,断开两个交换机的f1/2接口,查看连通性。事先使用PC1PC3进行长PING

    • 断开接口
    SW1(config-if-range)#ex
    SW1(config)#int f1/2
    SW1(config-if)#sh
    SW1(config-if)#
    *Mar  1 01:05:35.947: %EC-5-UNBUNDLE: Interface Fa1/2 left the port-channel Po1
    *Mar  1 01:05:35.995: %EC-5-BUNDLE: Interface Fa1/3 joined port-channel Po1
    *Mar  1 01:05:36.451: %DTP-5-NONTRUNKPORTON: Port Fa1/2 has become non-trunk
    *Mar  1 01:05:36.491: %DTP-5-TRUNKPORTON: Port Fa1/3 has become dot1q trunk
    SW1(config-if)#
    *Mar  1 01:05:37.887: %LINK-5-CHANGED: Interface FastEthernet1/2, changed state to administratively down
    SW1(config-if)#
    *Mar  1 01:05:37.947: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
    SW1(config-if)#
    *Mar  1 01:05:38.887: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/2, changed state to down
    *Mar  1 01:05:38.991: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up
    
    SW2(config-if-range)#ex
    SW2(config)#int f1/2
    SW2(config-if)#sh
    SW2(config-if)#
    *Mar  1 01:06:57.415: %EC-5-UNBUNDLE: Interface Fa1/2 left the port-channel Po1
    *Mar  1 01:06:57.447: %EC-5-BUNDLE: Interface Fa1/3 joined port-channel Po1
    *Mar  1 01:06:57.915: %DTP-5-NONTRUNKPORTON: Port Fa1/2 has become non-trunk
    *Mar  1 01:06:57.947: %DTP-5-TRUNKPORTON: Port Fa1/3 has become dot1q trunk
    SW2(config-if)#
    *Mar  1 01:06:59.375: %LINK-5-CHANGED: Interface FastEthernet1/2, changed state to administratively down
    SW2(config-if)#
    *Mar  1 01:06:59.411: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
    SW2(config-if)#
    *Mar  1 01:07:00.375: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/2, changed state to down
    *Mar  1 01:07:00.443: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up
    
    • PING 测试
    PC1> ping 192.168.10.30 -t
    84 bytes from 192.168.10.30 icmp_seq=1 ttl=64 time=1.975 ms
    84 bytes from 192.168.10.30 icmp_seq=2 ttl=64 time=1.866 ms
    84 bytes from 192.168.10.30 icmp_seq=3 ttl=64 time=1.849 ms
    84 bytes from 192.168.10.30 icmp_seq=4 ttl=64 time=0.978 ms
    84 bytes from 192.168.10.30 icmp_seq=5 ttl=64 time=1.851 ms
    84 bytes from 192.168.10.30 icmp_seq=6 ttl=64 time=1.842 ms
    84 bytes from 192.168.10.30 icmp_seq=7 ttl=64 time=1.896 ms
    84 bytes from 192.168.10.30 icmp_seq=8 ttl=64 time=1.879 ms
    84 bytes from 192.168.10.30 icmp_seq=9 ttl=64 time=1.877 ms
    84 bytes from 192.168.10.30 icmp_seq=10 ttl=64 time=1.853 ms
    84 bytes from 192.168.10.30 icmp_seq=11 ttl=64 time=1.988 ms
    84 bytes from 192.168.10.30 icmp_seq=12 ttl=64 time=1.846 ms
    84 bytes from 192.168.10.30 icmp_seq=13 ttl=64 time=1.839 ms
    84 bytes from 192.168.10.30 icmp_seq=14 ttl=64 time=1.996 ms
    84 bytes from 192.168.10.30 icmp_seq=15 ttl=64 time=1.847 ms
    84 bytes from 192.168.10.30 icmp_seq=16 ttl=64 time=1.862 ms
    84 bytes from 192.168.10.30 icmp_seq=17 ttl=64 time=1.847 ms
    84 bytes from 192.168.10.30 icmp_seq=18 ttl=64 time=1.886 ms
    84 bytes from 192.168.10.30 icmp_seq=19 ttl=64 time=1.849 ms
    84 bytes from 192.168.10.30 icmp_seq=20 ttl=64 time=1.844 ms
    84 bytes from 192.168.10.30 icmp_seq=21 ttl=64 time=1.886 ms
    84 bytes from 192.168.10.30 icmp_seq=22 ttl=64 time=1.844 ms
    84 bytes from 192.168.10.30 icmp_seq=23 ttl=64 time=1.889 ms
    84 bytes from 192.168.10.30 icmp_seq=24 ttl=64 time=1.858 ms
    84 bytes from 192.168.10.30 icmp_seq=25 ttl=64 time=1.965 ms
    84 bytes from 192.168.10.30 icmp_seq=26 ttl=64 time=1.842 ms
    84 bytes from 192.168.10.30 icmp_seq=27 ttl=64 time=1.848 ms
    84 bytes from 192.168.10.30 icmp_seq=28 ttl=64 time=1.997 ms
    84 bytes from 192.168.10.30 icmp_seq=29 ttl=64 time=1.843 ms
    84 bytes from 192.168.10.30 icmp_seq=30 ttl=64 time=1.972 ms
    84 bytes from 192.168.10.30 icmp_seq=31 ttl=64 time=1.847 ms
    84 bytes from 192.168.10.30 icmp_seq=32 ttl=64 time=1.844 ms
    84 bytes from 192.168.10.30 icmp_seq=33 ttl=64 time=0.968 ms
    192.168.10.30 icmp_seq=34 timeout
    192.168.10.30 icmp_seq=35 timeout
    192.168.10.30 icmp_seq=36 timeout
    192.168.10.30 icmp_seq=37 timeout
    192.168.10.30 icmp_seq=38 timeout
    192.168.10.30 icmp_seq=39 timeout
    192.168.10.30 icmp_seq=40 timeout
    192.168.10.30 icmp_seq=41 timeout
    192.168.10.30 icmp_seq=42 timeout
    192.168.10.30 icmp_seq=43 timeout
    192.168.10.30 icmp_seq=44 timeout
    192.168.10.30 icmp_seq=45 timeout
    192.168.10.30 icmp_seq=46 timeout
    192.168.10.30 icmp_seq=47 timeout
    192.168.10.30 icmp_seq=48 timeout
    192.168.10.30 icmp_seq=49 timeout
    192.168.10.30 icmp_seq=50 timeout
    192.168.10.30 icmp_seq=51 timeout
    192.168.10.30 icmp_seq=52 timeout
    192.168.10.30 icmp_seq=53 timeout
    192.168.10.30 icmp_seq=54 timeout
    192.168.10.30 icmp_seq=55 timeout
    192.168.10.30 icmp_seq=56 timeout
    192.168.10.30 icmp_seq=57 timeout
    192.168.10.30 icmp_seq=58 timeout
    192.168.10.30 icmp_seq=59 timeout
    192.168.10.30 icmp_seq=60 timeout
    192.168.10.30 icmp_seq=61 timeout
    192.168.10.30 icmp_seq=62 timeout
    192.168.10.30 icmp_seq=63 timeout
    192.168.10.30 icmp_seq=64 timeout
    192.168.10.30 icmp_seq=65 timeout
    192.168.10.30 icmp_seq=66 timeout
    192.168.10.30 icmp_seq=67 timeout
    192.168.10.30 icmp_seq=68 timeout
    192.168.10.30 icmp_seq=69 timeout
    192.168.10.30 icmp_seq=70 timeout
    192.168.10.30 icmp_seq=71 timeout
    192.168.10.30 icmp_seq=72 timeout
    192.168.10.30 icmp_seq=73 timeout
    192.168.10.30 icmp_seq=74 timeout
    192.168.10.30 icmp_seq=75 timeout
    192.168.10.30 icmp_seq=76 timeout
    192.168.10.30 icmp_seq=77 timeout
    192.168.10.30 icmp_seq=78 timeout
    192.168.10.30 icmp_seq=79 timeout
    192.168.10.30 icmp_seq=80 timeout
    192.168.10.30 icmp_seq=81 timeout
    192.168.10.30 icmp_seq=82 timeout
    192.168.10.30 icmp_seq=83 timeout
    192.168.10.30 icmp_seq=84 timeout
    192.168.10.30 icmp_seq=85 timeout
    192.168.10.30 icmp_seq=86 timeout
    192.168.10.30 icmp_seq=87 timeout
    192.168.10.30 icmp_seq=88 timeout
    192.168.10.30 icmp_seq=89 timeout
    84 bytes from 192.168.10.30 icmp_seq=90 ttl=64 time=1.846 ms
    84 bytes from 192.168.10.30 icmp_seq=91 ttl=64 time=1.982 ms
    84 bytes from 192.168.10.30 icmp_seq=92 ttl=64 time=1.840 ms
    84 bytes from 192.168.10.30 icmp_seq=93 ttl=64 time=1.849 ms
    84 bytes from 192.168.10.30 icmp_seq=94 ttl=64 time=1.841 ms
    84 bytes from 192.168.10.30 icmp_seq=95 ttl=64 time=1.846 ms
    84 bytes from 192.168.10.30 icmp_seq=96 ttl=64 time=1.841 ms
    84 bytes from 192.168.10.30 icmp_seq=97 ttl=64 time=1.861 ms
    84 bytes from 192.168.10.30 icmp_seq=98 ttl=64 time=0.844 ms
    84 bytes from 192.168.10.30 icmp_seq=99 ttl=64 time=0.833 ms
    

    最后

    这是关于使用Trunk实现跨交换机VLAN通信的实验,和以太网通道怎么创建方法。下一篇关于三层交换的实验。

  • 相关阅读:
    点击空白处回收键盘
    数据处理文件读取---预习 1.30
    界面通信之属性传值、代理传值
    UITableView的添加、删除、移动操作
    加载plist文件数据的方法
    UITableViewCell的重用机制
    自定义cell自适应高度
    关于Xcode7更新之后使用 SDWebImage 图片加载不出来
    简述frame、bounds、center
    layoutSubviews方法需要被调用的情况有哪些
  • 原文地址:https://www.cnblogs.com/llife/p/11329350.html
Copyright © 2011-2022 走看看