Vlan简介
虚拟局域网(VLAN)是一组由拥有共同需求且与物理位置无关的终端设备所组成的逻辑分组。通过在交换机上划分vlan,可以实现在同一vlan内的用户二层互访,不同vlan中的用户无法互访,既隔绝了广播域,提升安全性和可靠性,又不影响用户通信。
Vlan配置
SW核心:
vlan batch 10 20 30
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan all
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan all
SW1:
vlan 10
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface Ethernet0/0/2
port link-type access
port default vlan 10
interface Ethernet0/0/3
port link-type access
port default vlan 10
SW2:
vlan 20
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface Ethernet0/0/2
port link-type access
port default vlan 20
SW3:
vlan 30
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface Ethernet0/0/2
port link-type access
port default vlan 30
Vlan通信原理
A、PC无法识别和处理带有vlan标签的报文
B、报文在通过access口时,会去除vlan标签
C、报文只有在trunk链路中才会携带标签
D、报文在交换机内部处理时,必须携带标签
Trunk、Access、Hybrid简介
Access类型端口:只能属于1个VLAN,一般用于连接计算机端口。
Trunk类型端口:可以允许多个VLAN通过,可以接收和发送多个VLAN 报文,一般用于交换机与交换机相关的接口。
Hybrid类型端口:可以允许多个VLAN通过,可以接收和发送多个VLAN 报文,可以用于交换机的间连接也可以用于连接用户计算机。
Vlan间路由
(1) 单臂路由![在这里插入图片描述](https://img-blog.csdnimg.cn/20200528164518842.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW9oYW4yMDk=,size_16,color_FFFFFF,t_70#pic_center)
SW1:
vlan batch 10 20
interface Ethernet0/0/1
port link-type access
port default vlan 10
interface Ethernet0/0/2
port link-type access
port default vlan 20
interface Ethernet0/0/3
port link-type trunk
port trunk allow-pass vlan all
R1:
interface Ethernet0/0/0.1
dot1q termination vid 10
ip address 192.168.10.1 255.255.255.0
arp broadcast enable
interface Ethernet0/0/0.2
dot1q termination vid 20
ip address 192.168.20.1 255.255.255.0
arp broadcast enable
(2) SVI路由
核心左:
interface Vlanif10
ip address 192.168.10.1 255.255.255.0
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
interface Vlanif30
ip address 192.168.30.1 255.255.255.0
核心右:
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
interface Vlanif30
ip address 192.168.30.1 255.255.255.0
所有交换机与交换机相连的端口全部配置为trunk,以便让全部的vlan通过。