实验目的
掌握三层交换路由的配置
实验拓扑
实验要求
1. 利用路由器R1和R2模拟PC1和PC2,关闭路由功能
2.将路由器R1的e0/0端口的IP设置为:192.168.0.10/24 默认网关设为:192.168.0.1
3.将路由器R2的e0/0端口的IP设为:192.168.1.10/24 默认网关设为:192.168.1.1
4. 将交换机SW1开启路由功能作为三层交换机使用,并将F0/1端口划分到VLAN10中、F0/2端口划分到VLAN20中
实验步骤:
步骤1.在R1的配置
R1#
configure terminal
R1(config)# no ip routing //关闭R1的路由功能,模拟PC1
R1(config)# ip default-gateway 192.168.0.1 //指定R1的默认网关为192.168.0.1
R1(config)# interface e0/0
R1(config-if)# duplex full //e0/0端口默认方式为half-duplex,将其强制设置为full-duplex使之与交换机SW1的端口F0/1相匹配
R1(config-if)# ip address 192.168.0.10 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# end
R1(config)# no ip routing //关闭R1的路由功能,模拟PC1
R1(config)# ip default-gateway 192.168.0.1 //指定R1的默认网关为192.168.0.1
R1(config)# interface e0/0
R1(config-if)# duplex full //e0/0端口默认方式为half-duplex,将其强制设置为full-duplex使之与交换机SW1的端口F0/1相匹配
R1(config-if)# ip address 192.168.0.10 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# end
步骤2 在R2上进行配置
R2#
configure terminal
R2(config)#
no ip routing
//关闭R2的路由功能将其模拟为PC2
R2(config)# ip default-gateway 192.168.1.1 //指定R2的默认网关为192.168.1.1
R2(config)# interface e0/0
R2(config-if)# duplex full //因e0/0端口默认方式为half-duplex,将其强制设置为full-duplex使之与接入交换机SW1的端口F0/2相匹配
R2(config-if)# ip address 192.168.1.10 255.255.255.0
R2(config-if)# no shutdown
R2(config)# ip default-gateway 192.168.1.1 //指定R2的默认网关为192.168.1.1
R2(config)# interface e0/0
R2(config-if)# duplex full //因e0/0端口默认方式为half-duplex,将其强制设置为full-duplex使之与接入交换机SW1的端口F0/2相匹配
R2(config-if)# ip address 192.168.1.10 255.255.255.0
R2(config-if)# no shutdown
步骤3. 在SW1上划分VLAN 并将端口加入VLAN中
SW1#
vlan database
//进入数据库模式
SW1(vlan)# vlan 10 //新建VLAN
VLAN 10 added:
Name: VLAN0010
SW1(vlan)# vlan 20
VLAN 20 added:
Name: VLAN0020
SW1(vlan)# exit //退出数据库模式,使配置生效。
APPLY completed.
Exiting….
SW1(vlan)# vlan 10 //新建VLAN
VLAN 10 added:
Name: VLAN0010
SW1(vlan)# vlan 20
VLAN 20 added:
Name: VLAN0020
SW1(vlan)# exit //退出数据库模式,使配置生效。
APPLY completed.
Exiting….
SW1(config)#
interface f0/1
SW1(config-if)# switchport mode access //将接口模式设置为接入模式
SW1(config-if)# switchport access vlan 10 //将接口划入VLAN中
SW1(config-if)# no shutdown
SW1(config-if)# interface f0/2
SW1(config-if)# switchport mode access
SW1(config-if)# switchport mode access //将接口模式设置为接入模式
SW1(config-if)# switchport access vlan 10 //将接口划入VLAN中
SW1(config-if)# no shutdown
SW1(config-if)# interface f0/2
SW1(config-if)# switchport mode access
SW1(config-if)#
switchport access vlan 20
SW1(config-if)# no shutdown
SW1(config-if)# no shutdown
步骤4 测试R1和R2的连通性
R2#
pin 192.168.0.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.10, timeout is 2 seconds:
…..
Sending 5, 100-byte ICMP Echos to 192.168.0.10, timeout is 2 seconds:
…..
//测试失败!!!说明R1和R2之间不能通信,因为他们在不同的VLAN中。那么为了让他们通信。我们需要在三层交换机上配置。
步骤5 在SW1上配置SVI(
Switched Virtual Interface)接口
SW1(config)#
interface vlan 10
//进入VLAN10
SW1(config-if)# ip address 192.168.0.1 255.255.255.0 //将VLAN10的SVI接口地址设置为R1指向的默认网关地址
SW1(config-if)# no shutdown
SW1(config-if)# interface vlan 20
SW1(config-if)# ip address 192.168.1.1 255.255.255.0
SW1(config-if)# ip address 192.168.0.1 255.255.255.0 //将VLAN10的SVI接口地址设置为R1指向的默认网关地址
SW1(config-if)# no shutdown
SW1(config-if)# interface vlan 20
SW1(config-if)# ip address 192.168.1.1 255.255.255.0
//将VLAN20的SVI接口地址设置为R2指向的默认网关地址
SW1(config-if)# no shutdown
SW1(config-if)# no shutdown
步骤6 验证R1和R2之间的连通性
R1#
ping 192.168.1.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
!!!!!
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
!!!!!
R2#
pin 192.168.0.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.10, timeout is 2 seconds:
!!!!!
Sending 5, 100-byte ICMP Echos to 192.168.0.10, timeout is 2 seconds:
!!!!!
//通过验证发现R1和R2可以相互通信。这样我们就达到了通过在三层交换机做SVI配置使不同VLAN 之间相互通信的目的。
©著作权归作者所有:来自51CTO博客作者ljp0501的原创作品,如需转载,请注明出处,否则将追究法律责任
0
收藏
转载于:https://blog.51cto.com/ljp0501/143125