单臂路由和三层交换

VLAN之间通讯不同实现方式

1.单臂路由

1.1 单臂路由实现不同VLAN间通信

  • 链路类型
    • 交换机连接主机的端口为access链路
    • 交换机连接路由器的端口为Trunk链路
  • 子接口
    • 路由器的物理接口可以被划分成多个逻辑接口
    • 每个子接口对应一个VLAN网段的网关

原理: 路由器重新封装MAC地址,转换Vlan标签

1、配置交换机的链路类型,连接路由器的接口为trunk,连接主机的为access

2、配置vlan标签的封装结构和子接口地址

1.2 实验:

bash 复制代码
#交换机配置
<Huawei>u t m
[SW1]vlan batch 10 20

[SW1]int e0/0/1
[SW1-Ethernet0/0/1]port link-type access 
[SW1-Ethernet0/0/1]port default vlan 10
[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]port link-type access
[SW1-Ethernet0/0/2]port default vlan 20
[SW1-Ethernet0/0/2]u sh

[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]port link-type trunk 
[SW1-Ethernet0/0/3]port trunk allow-pass vlan all
[SW1-Ethernet0/0/3]u sh


#路由器配置
[R1]int g0/0/0.10
# 0-4095
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.10]ip add 192.168.10.1 24
[R1-GigabitEthernet0/0/0.10]arp broadcast enable      
#一定要开启arp广播( mac地址和ip地址转换 )
[R1-GigabitEthernet0/0/0.10]u sh
[R1]int g0/0/0.20
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]ip add 192.168.20.1 24
[R1-GigabitEthernet0/0/0.20]u sh
[R1-GigabitEthernet0/0/0.20]arp broadcast enable
#一定要开启
<R1>display interface brief 

2. 三层交换机

三层交换技术可以实现VLAN间通信

vlanif(vlanint) 三层接口


2.1 FIB(转发信息库): 路由表

FIB从概念上讲类似于路由表,它维护着一个IP路由表中包含的转发信息的镜象。当网络中路由或拓朴结构发生了变化时,IP路由表就被更新,而这些变化也反映在FIB中。FIB基于IP路由表中信息,维护着下一网络段的地址信息。是路由表一个镜像,路由表更新时,FIB随之变化,其中FIB包含邻接主机的IP地址与VID的对应关系。

2.2 邻接关系表

邻接关系表包含邻接主机和交换机MAC地址的对应关系用来提供二层重写信息。

2.3 三层交换机实现vlan之间通信的原理

每一个 vlan都会虚拟出一个虚拟接口,然后在虚拟接口上配置ip地址

工作原理

①主机A给B发送单播数据包

②交换机查找FIB表,找到下一跳地址

③查找下一跳地址对应的邻接关系的2层封装信息

④转发

注意:三层交换机不具备路由器特有的NAT、vpn 等技术。

2.4 实验:

bash 复制代码
[Huawei]vlan b 10 20 30
[Huawei-Ethernet0/0/1]int e0/0/1
[Huawei-Ethernet0/0/1]p l a
[Huawei-Ethernet0/0/1]p d v 10
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l a
[Huawei-Ethernet0/0/2]p d v 20
[Huawei-Ethernet0/0/2]undo sh
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l a
[Huawei-Ethernet0/0/3]p d v 30
[Huawei-Ethernet0/0/3]undo sh
[Huawei-Ethernet0/0/3]int e0/0/4
[Huawei-Ethernet0/0/4]p l t 
[Huawei-Ethernet0/0/4]p t a v a
[Huawei-Ethernet0/0/4]dis th

#####在三层交换机上配置的VLAN接口为虚接口
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a v a

[SW2]vlan batch 10 20 30

[Huawei] int Vlanif 10
#给vlan配置地址
[Huawei-Vlanif10]ip address 192.168.10.254 24
[Huawei-Vlanif10]display ip interface brief    ###端口自动激活

 interface Vlanif 20
  
 interface Vlanif 30
相关推荐
liulilittle13 分钟前
VGW 虚拟网关用户手册 (PPP PRIVATE NETWORK 基础设施)
开发语言·网络·c++·网关·智能路由器·路由器·通信
网硕互联的小客服15 分钟前
服务器如何配置防火墙规则以阻止恶意流量和DDoS攻击?
服务器·网络·ddos
Qiq92218 分钟前
怎么分析内网ipv6和ipv4流量占比?
网络
数通Dinner28 分钟前
P/A初始化协商
网络
网安小白的进阶之路29 分钟前
A模块 系统与网络安全 第三门课 网络通信原理-3
网络·windows·安全·web安全·系统安全
HumanRisk36 分钟前
HumanRisk-自动化安全意识与合规教育平台方案
网络·安全·web安全·网络安全意识教育
网络小白不怕黑39 分钟前
华为设备 QoS 流分类与流标记深度解析及实验脚本
网络·华为
网络小白不怕黑43 分钟前
华为交换机堆叠与集群技术深度解析附带脚本
网络·华为
靡樊2 小时前
NAT、代理服务、内网穿透
网络·内网穿透·nat·代理服务·内网打洞