「CCNA实验分享」三层交换机Vlan间路由

2023-05-03 05:01:00

实验目的:

使用L3交换机做Vlan间的路由

实验说明:

单臂路由虽然可以实现不同vlan间的相互通信,因为性能较差,所以不推荐使用。一般中大型网络不同网段间路由都采用高性能的L3交换机。

实验拓扑图:

实验步骤:

1.配置Core交换机

Switch(config)#hostname Core

Core(config)#vlan 10

Core(config-vlan)#name engineering

Core(config-vlan)#vlan 20

Core(config-vlan)#name RD

Core(config-vlan)#vlan 30

Core(config-vlan)#name ServerFarm

Core(config-vlan)#vlan 40

Core(config-vlan)#name MGT-vlan

Core(config-vlan)#exit

Core(config)#int vlan 10

Core(config-if)#no shut

Core(config-if)#ip address 192.168.10.254 255.255.255.0{创建三层SVI接口,并配置IP地址}

Core(config-if)#int vlan 20

Core(config-if)#ip address 192.168.20.254 255.255.255.0

Core(config-if)#no shutdown

Core(config-if)#int vlan 30

Core(config-if)#ip address 192.168.30.254 255.255.255.0

Core(config-if)#no shutdown

Core(config-if)#int vlan 40

Core(config-if)#ip address 192.168.40.254 255.255.255.0

Core(config-if)#no shutdown

Core(config-if)#exit

Core(config)#ip routing{启用L3交换机的路由功能}

Core(config)#int range f0/1 - 2

Core(config-if-range)#switch mode access

Core(config-if-range)#switch access vlan 30

Core(config-if-range)#spanning-tree portfast

Core(config-if-range)#exit

Core(config)#int f0/24

Core(config-if)#switchport trunk encapsulation dot1q

Core(config-if)#switchport mode trunk

Core(config-if)#exit

Core(config)#line vty 0 4

Core(config-line)#login

Core(config-line)#password G-LAB

Core(config-line)#exit

Core(config)#enable secret G-LAB

2.配置ED-SW交换机

Switch>enable

Switch#

Switch(config)#hostname ED-SW

ED-SW(config)#vlan 10

ED-SW(config-vlan)#name engineering

ED-SW(config-vlan)#vlan 20

ED-SW(config-vlan)#name RD

ED-SW(config-vlan)#vlan 40

ED-SW(config-vlan)#name MGT-vlan

ED-SW(config-vlan)#exit

ED-SW(config)#int range f0/1 – 5

ED-SW(config-if-range)#switch mode access

ED-SW(config-if-range)#switch access vlan 10

ED-SW(config-if-range)#spanning-tree portfast

ED-SW(config)#int range f0/6 – 10

ED-SW(config-if-range)#switch mode access

ED-SW(config-if-range)#switch access vlan 20

ED-SW(config-if-range)#spanning-tree portfast

ED-SW(config-if-range)exit

ED-SW(config)#interface fa0/12

ED-SW(config-if)#switch mode trunk

ED-SW(config-if)#exit

ED-SW(config)#int vlan 40

ED-SW(config-if)#ip address 192.168.40.200 255.255.255.0

ED-SW(config-if)#no shut

ED-SW(config-if)#exit

ED-SW(config)#ip default-gateway 192.168.40.254

ED-SW(config)#line vty 0 4

ED-SW(config-line)#login

ED-SW(config-line)#password G-LAB

ED-SW(config-line)#exit

ED-SW(config)#enable secret G-LAB

3. 测试

PC1:192.168.10.11/24 default-gateway:192.168.10.254

PC2:192.168.20.11/24 default-gateway:192.168.20.254

Server:192.168.30.22/24 default-gateway:192.168.30.254

PC1连结到ED-SW Fa0/1

PC2连结到ED-SW Fa0/6

Server连接到Core-SW Fa0/1

C:\Documents and Settings\Joseph>ping{在PC1上做ping测试} 192.168.10.254


Pinging 192.168.10.254 with 32 bytes of data:


Reply from 192.168.10.254: bytes=32 time=1ms TTL=64

Reply from 192.168.10.254: bytes=32 time=1ms TTL=64

Reply from 192.168.10.254: bytes=32 time=1ms TTL=64

Reply from 192.168.10.254: bytes=32 time=1ms TTL=64


Ping statistics for 192.168.10.254:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 1ms, Maximum = 1ms, Average = 1ms


C:\Documents and Settings\Joseph>{在PC1上做ping测试}ping 192.168.20.254


Pinging 192.168.20.254 with 32 bytes of data:


Reply from 192.168.20.254: bytes=32 time=1ms TTL=64

Reply from 192.168.20.254: bytes=32 time=1ms TTL=64

Reply from 192.168.20.254: bytes=32 time=1ms TTL=64

Reply from 192.168.20.254: bytes=32 time=1ms TTL=64


Ping statistics for 192.168.20.254:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 1ms, Maximum = 1ms, Average = 1ms


C:\Documents and Settings\Joseph>{在PC1上做ping测试}ping 192.168.30.22


Pinging 192.168.30.22 with 32 bytes of data:


Reply from 192.168.30.22: bytes=32 time=1ms TTL=63{TTL值减少了1,说明经过了一台路由器}

Reply from 192.168.30.22: bytes=32 time=1ms TTL=63

Reply from 192.168.30.22: bytes=32 time=1ms TTL=63

Reply from 192.168.30.22: bytes=32 time=1ms TTL=63


Ping statistics for 192.168.30.22:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 1ms, Maximum = 1ms, Average = 1ms


Core#sh 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

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

C 192.168.30.0/24 is directly connected, Vlan30

C 192.168.10.0/24 is directly connected, Vlan10

C 192.168.40.0/24 is directly connected, Vlan40

C 192.168.20.0/24 is directly connected, Vlan20{可以直接到达vlan10、20、30、40几个vlan。}


ED-SW#ping 192.168.40.254

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.40.254, timeout is 2 seconds:

!!!!!{ED-SW可以与Core互通}

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/202/1004 ms

ED-SW#sh vlan b

VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active

10 test active Fa0/1, Fa0/2, Fa0/3, Fa0/4

Fa0/5

20 RD active Fa0/6, Fa0/7, Fa0/8, Fa0/9

Fa0/10

40 MGT-VLAN active

1002 fddi-default active

1003 token-ring-default active

1004 fddinet-default active

1005 trnet-default active


ED-SW#telnet 192.168.40.254

Trying 192.168.40.254 ... Open{说明ED-SW可以从远程登录到Core做管理}


User Access Verification

Password: G-LAB

Core>en

Password: G-LAB

Core#


Core#telnet 192.168.40.200 /source-interface vlan 40

Trying 192.168.40.200 ... Open{说明可以从其他的vlan远程登入到ED-SW作跨网段管理}


User Access Verification

Password: G-LAB

ED-SW>en

Password: G-LAB

ED-SW#

4.实验完成