单臂路由
单臂路由概念:单臂路由是指在路由器的一个接口上通过配置子接口的方式,实现原来相互隔离的不同VLAN之间的互联互通。
单臂路由优点
可以实现原来不同VLAN之间的互联互通。
单臂路由的配置
- 配置链路类型
- 配置VLAN标签的封装结构
- 配置子接口地址
实验拓扑
(1)配置主机IP
(2)在交换机中创建VLAN,将端口加入到相应的VLAN中。
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW1
[SW1]vlan batch 10 20 //创建vlan10、vlan20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int e0/0/1 //进入接口e0/0/1
[SW1-Ethernet0/0/1]p l a //设置接口模式为access模式
[SW1-Ethernet0/0/1]p d v 10 //将该接口加入vlan10
[SW1-Ethernet0/0/1]undo shutdown //开启接口
Info: Interface Ethernet0/0/1 is not shutdown.
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]undo shutdown
Info: Interface Ethernet0/0/2 is not shutdown.
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]p l t //设置接口模式为trunk模式
[SW1-Ethernet0/0/3]p t a v a //允许所有vlan通过该接口
[SW1-Ethernet0/0/3]undo shutdown
Info: Interface Ethernet0/0/3 is not shutdown.
(3)在路由器中配置VLAN标签的封装结构和子接口地址。
(4)验证实验结果
PC1能与PC2通信
三层交换
三层交换机简介
三层交换机就是具有部分路由器功能的交换机,工作在OSI网络标准模型的第三层:网络层。三层交换机的最重要目的是加快大型局域网内部的数据交换,所具有的路由功能也是为这目的服务的,能够做到一次路由,多次转发。
三层交换机的虚接口
三层交换机具备路由功能,所以两个VLAN之间可以互相访问,每一个VLAN虚接口就是该网段的网关。
三层交换机的配置
实验拓扑
(1)设置三台主机的IP地址和子网掩码。
(2)在二层交换机中分别创建VLAN10、VLAN20、VLAN30,分配端口到相应的VLAN。
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW2
[SW2]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]p l a
[SW2-Ethernet0/0/1]p d v 10
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]p l a
[SW2-Ethernet0/0/2]p d v 20
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 30
[SW2-Ethernet0/0/3]int e0/0/4
[SW2-Ethernet0/0/4]p l t
[SW2-Ethernet0/0/4]p t a v a
[SW2-Ethernet0/0/4]
(3)在三层交换机中分别创建vlan10、vlan20、vlan30,并配置其虚接口的ip地址(即三台主机分别对应的网关地址)。
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW1
[SW1]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]p l t
[SW1-GigabitEthernet0/0/1]p t a v a
[SW1-GigabitEthernet0/0/1]int vlanif 10 //进入vlan10的虚接口
[SW1-Vlanif10]ip add 192.168.10.1 24 //配置IP地址
[SW1-Vlanif10]int vlanif 20
[SW1-Vlanif20]ip add 192.168.20.1 24
[SW1-Vlanif20]int vlanif 30
[SW1-Vlanif30]ip add 192.168.30.1 24
(4)验证实验结果,查看三台主机之间能否相互通信
用PC1 ping PC2能够进行通信,PC1 ping PC3,也能够进行通信。 实验成功。
实验拓扑2
(1)配置主机的IP子网和网关
(2)配置交换机SW1
(3)配置交换机SW2
[SW2-GigabitEthernet0/0/2]int vlanif 10//进入vlanif10虚拟接口
[SW2-Vlanif10]ip add 192.168.1.254 24//配置ip地址
[SW2-Vlanif10]int vlanif 20
[SW2-Vlanif20]ip add 192.168.2.254 24
[SW2-Vlanif20]int vlanif 30
[SW2-Vlanif30]ip add 192.168.3.254 24
[SW2-Vlanif30]int vlanif 100
[SW2-Vlanif100]ip add 192.168.4.1
[SW2]ip route-static 192.168.5.0 24 192.168.4.2//配置静态
(4)配置路由R1
[R1]int g0/0/0 //进入端口
[R1-GigabitEthernet0/0/0]ip add 192.168.4.2 24 //配置ip
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.5.254 24
[R1-GigabitEthernet0/0/1]ip route-s
[R1-GigabitEthernet0/0/1]q
[R1]ip route-s
[R1]ip route-static 0.0.0.0 0 192.168.4.1 //配置默认路由
(5)验证通信
PC1能与PC4通信,实验成功