【实操】配置VLAN间路由
原创:厦门微思网络
点击查看【相关学习】
【干货】什么是VLAN?
【技术分享】常见VLAN部署方式
【必看】华为设备配置单臂路由实现VLAN间通信
实验目的
1. 理解VLAN间路由的原理
2. 掌握VLAN间路由的配置方法
实验拓扑
实验需求
1、根据实验拓扑图,完成设备的基本配置;
2、配置单臂路由实现VLAN10和VLAN20之间的互访。
实验步骤
步骤1:设备的基本配置
配置PC1:
VPCS> set pcname PC1 //设置主机名
PC1> ip 192.168.1.1/24 192.168.1.254 //设置IP地址与网关
配置PC2:
VPCS> set pcname PC2
PC2> ip 172.16.1.1/24 172.16.1.254
配置R1:
Router
>enable
Router#configure terminal
Router(config)#hostname R1
R1(config)#no ip domain-lookup
R1(config)#line console 0
R1(config-line)#exec-timeout 0 0
R1(config-line)#logging synchronous
R1(config-line)#end
R1#
配置SW1:
Switch>enable
Switch#configure terminal
Switch(config)#hostname SW1
SW1(config)#no ip domain-lookup
SW1(config)#line console 0
SW1(config-line)#exec-timeout 0 0
SW1(config-line)#logging synchronous
SW1(config-line)#end
SW1#
步骤2:单臂路由的配置
配置R1:
R1(config)#interface Ethernet0/0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface Ethernet0/0.10
R1(config-if)#encapsulation dot1Q 10
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#exit
R1(config)#interface Ethernet0/0.20
R1(config-if)#encapsulation dot1Q 20
R1(config-if)#ip address 172.16.1.254 255.255.255.0
R1(config-if)#end
R1#
配置SW1:
SW1(config)#vlan 10
SW1(config-vlan)#name IT
SW1(config-vlan)#exit
SW1(config)#vlan 20
SW1(config-vlan)#name HR
SW1(config-vlan)#exit
SW1(config)#interface Ethernet0/0
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport mode trunk
SW1(config)#interface Ethernet0/1
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW1(config)#interface Ethernet0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 20
实验检查
步骤1:检查R1
检查R1的接口状态:
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset up up
Ethernet0/0.10192.168.1.254YES manual up up
Ethernet0/0.20172.16.1.254YES manual up up
Ethernet0/1 unassigned YES unset administratively down down
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
检查R1的子接口信息:
R1#showvlans
VirtualLAN ID: 1 (IEEE 802.1Q Encapsulation)
vLANTrunk Interface: Ethernet0/0
Thisis configured as native Vlan for the following interface(s) :
Ethernet0/0
ProtocolsConfigured: Address: Received: Transmitted:
Ethernet0/0(1)
Other0 20
0packets, 0 bytes input
20packets, 1440 bytes output
VirtualLAN ID: 10 (IEEE 802.1Q Encapsulation)
vLANTrunk Interface: Ethernet0/0.10
ProtocolsConfigured: Address: Received: Transmitted:
Ethernet0/0.10(10)
IP192.168.1.254 14 9
Other0 3
72packets, 5232 bytes input
12packets, 1056 bytes output
VirtualLAN ID: 20 (IEEE 802.1Q Encapsulation)
vLANTrunk Interface: Ethernet0/0.20
ProtocolsConfigured: Address: Received: Transmitted:
Ethernet0/0.20(20)
IP172.16.1.254 14 9
Other0 3
72packets, 5232 bytes input
12packets, 1056 bytes output
子接口E0/0.10的VLANID是10,IP地址是192.168.1.254;
子接口E0/0.20的VLANID是20,IP地址是172.16.1.254。
步骤2:检查SW1
检查SW1的VLAN信息:
SW1#showvlan brief
VLANName Status Ports
------------------------------------ --------- -------------------------------
1default active Et0/3
10VLAN0010 active Et0/1
20VLAN0020 active Et0/2
1002fddi-default act/unsup
1003token-ring-default act/unsup
1004fddinet-default act/unsup
1005trnet-default act/unsup
检查SW1的Trunk状态:
SW1#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Et0/0 on 802.1q trunking 1
Port Vlans allowed on trunk
Et0/01-4094
Port Vlans allowed and active in management domain
Et0/01,10,20
Port Vlans in spanning tree forwarding state andnot pruned
Et0/01,10,20
步骤3:测试网络连通性
PC1访问PC2:
PC1> ping 172.16.1.1
84 bytes from172.16.1.1 icmp_seq=1 ttl=63 time=1.597 ms
84 bytes from172.16.1.1 icmp_seq=2 ttl=63 time=1.237 ms
84 bytes from172.16.1.1 icmp_seq=3 ttl=63 time=1.975 ms
84 bytes from172.16.1.1 icmp_seq=4 ttl=63 time=1.274 ms
84 bytes from172.16.1.1 icmp_seq=5 ttl=63 time=1.243 ms
PC1> trace 172.16.1.1
traceto 172.16.1.1, 8 hopsmax, pressCtrl+Ctostop
1 192.168.1.254 0.443ms 0.400ms 0.715ms
2 *172.16.1.1 1.938ms (ICMPtype:3, code:3, Destinationportunreachable)
通过Trace看到,数据包先到网关(R1),再到PC2。
END
微思网络,始于2002年
专业IT认证培训23年,面向全国招生!
微思-主要课程有:
*网络技术:华为HCIA/ HCIP/HCIE;思科CCNA/CCNP/CCIE
*Linux技术:红帽 RHCE/RHCA
*K8S&容器:CKA/CKS
*数据库:ORACLE OCP/ OCM ;MySQL ;达梦数据库
*虚拟化:VMware VCP/VCAP
*安全认证:CISP体系/CISSP/ CISA;CCSK;CISAW体系
*管理类:PMP 项目管理;软考中/高项;ITIL体系;Togaf
其他课程如:ACP;Azure...