Loading

使用三层交换实现不同网段、不同 VLAN 互通

GNS3图标

上一篇实现了使用Trunk做跨交换机VLAN通信,这一篇就试试使用三层交换实现不同网段,不同VLAN间的通信。


实验拓扑

拓扑

在一台三层交换机下面连接一台二层交换机,再在二层交换机下面连接两台VPC,地址规划如下:

名称 接口 VLAN 地址
PC1 SW1-f1/1 vlan 10 192.168.10.10/24
PC2 SW1-f1/2 vlan 20 192.168.20.10/24
名称 接口 地址
SW2 vlan 10 192.168.10.1/24
SW2 vlan 20 192.168.20.1/24

配置方法

SW2(config)#int vlan 10
SW2(config-if)#ip address 192.168.10.1 255.255.255.0
SW2(config-if)#no shutdown

配置过程

SW1

  • SW1关闭路由功能
SW1#conf t
SW1(config)#no ip routing
  • SW1创建VLAN 10VLAN 20,并添加接口。
SW1(config)#vlan 10,20
SW1(config-vlan)#ex
SW1(config)#int f1/1
SW1(config-if)#sw m a
SW1(config-if)#sw a v 10
SW1(config-if)#int f1/2
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/0, 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/1
20   VLAN0020                         active    Fa1/2
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup
  • SW1配置Trunk
SW1(config)#int f1/0
SW1(config-if)#sw m t
SW1(config-if)#sw t e d

SW2

  • SW2创建VLAN 10VLAN 20,并配置Trunk
SW2#conf t
SW2(config)#vlan 10,20
SW2(config-vlan)#ex
SW2(config)#int f1/0
SW2(config-if)#sw m t
SW2(config-if)#sw t e d
SW2(config-if)#ex
  • 虚接口配置ip地址,并查看
SW2(config)#int vlan 10
SW2(config-if)#ip address 192.168.10.1 255.255.255.0
SW2(config-if)#no shutdown
SW2(config-if)#int vlan 20
SW2(config-if)#ip add 192.168.20.1 255.255.255.0
SW2(config-if)#no sh
SW2(config-if)#do show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down
FastEthernet0/1            unassigned      YES unset  administratively down down
FastEthernet1/0            unassigned      YES unset  up                    up
FastEthernet1/1            unassigned      YES unset  up                    down
FastEthernet1/2            unassigned      YES unset  up                    down
FastEthernet1/3            unassigned      YES unset  up                    down
FastEthernet1/4            unassigned      YES unset  up                    down
FastEthernet1/5            unassigned      YES unset  up                    down
FastEthernet1/6            unassigned      YES unset  up                    down
FastEthernet1/7            unassigned      YES unset  up                    down
FastEthernet1/8            unassigned      YES unset  up                    down
FastEthernet1/9            unassigned      YES unset  up                    down
FastEthernet1/10           unassigned      YES unset  up                    down
FastEthernet1/11           unassigned      YES unset  up                    down
FastEthernet1/12           unassigned      YES unset  up                    down
FastEthernet1/13           unassigned      YES unset  up                    down
FastEthernet1/14           unassigned      YES unset  up                    down
FastEthernet1/15           unassigned      YES unset  up                    down
Vlan1                      unassigned      YES unset  up                    up
Vlan10                     192.168.10.1    YES manual up                    up
Vlan20                     192.168.20.1    YES manual up                    up

PING 测试

PC1> ip 192.168.10.10 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1

PC1> ping 192.168.20.10
192.168.20.10 icmp_seq=1 timeout
84 bytes from 192.168.20.10 icmp_seq=2 ttl=63 time=14.115 ms
84 bytes from 192.168.20.10 icmp_seq=3 ttl=63 time=18.948 ms
84 bytes from 192.168.20.10 icmp_seq=4 ttl=63 time=18.066 ms
84 bytes from 192.168.20.10 icmp_seq=5 ttl=63 time=11.972 ms
PC2> ip 192.168.20.10 192.168.20.1
Checking for duplicate address...
PC1 : 192.168.20.10 255.255.255.0 gateway 192.168.20.1

PC2> ping 192.168.10.10
84 bytes from 192.168.10.10 icmp_seq=1 ttl=63 time=20.966 ms
84 bytes from 192.168.10.10 icmp_seq=2 ttl=63 time=16.993 ms
84 bytes from 192.168.10.10 icmp_seq=3 ttl=63 time=14.945 ms
84 bytes from 192.168.10.10 icmp_seq=4 ttl=63 time=16.883 ms
84 bytes from 192.168.10.10 icmp_seq=5 ttl=63 time=18.054 ms

实现了不同网段,不同vlan互通。

最后

关于GNS3一些实验操作就暂告一段落了,最近几篇实验写的有点仓促,只写了主体部分,后期会慢慢会优化。

有关网络的基础知识原理之类的,等有空也会整理一波,巩固一下知识。

posted @ 2019-08-09 23:30  LinSenGeGe  阅读(4284)  评论(0编辑  收藏  举报