一、虚拟局域网----VLAN
1.VLAN概述
为了解决广播风暴,通常使用分隔广播域的方法来解决,分隔广播域的方法有两种
①物理分隔:将网络从物理上划分成一个个小网络
②逻辑分隔:将网络从逻辑上划分成一个个小的虚拟网络,即VLAN
2.VLAN优势
VLAN的产生给局域网的设计增加了灵活性和可扩展性,还具有以下优势
①控制广播
②增强网络安全性
③简化网络管理
3.VLAN标识
在以太网上实现中继,有两种封装方式
①ISL (cisco私有标准)
②IEEE 802.1q(下图为插入802.1q帧标识的标准以太网帧)
4.VLAN种类
静态VLAN:基于端口划分静态VLAN(常用)
动态VLAN:基于mac地址划分动态VLAN
5.Trunk
在交换网络中,有两种类型链路:
①接入链路:通常属于一个vlan。主机与交换机之间连接的链路就是接入链路
②中继链路:可以承载多个vlan。交换机机与交换机之间连接的链路就是接入链路
trunk的作用就是使同一个vlan能够跨交换机通信
二、实验练习
1.静态路由
实验要求:配置loopback接口,使得所有loopback接口互通
(1)R1配置
interface GigabitEthernet0/0/0
ip address 12.0.0.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 13.0.0.1 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
ip route-static 2.2.2.2 255.255.255.255 12.0.0.2
ip route-static 3.3.3.3 255.255.255.255 13.0.0.2
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
(2)配置
interface GigabitEthernet0/0/0
ip address 12.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.0.0.1 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
ip route-static 1.1.1.1 255.255.255.255 12.0.0.1
ip route-static 3.3.3.3 255.255.255.255 23.0.0.2
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
<R2>
(3)R3配置
interface GigabitEthernet0/0/0
ip address 13.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.0.0.2 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
ip route-static 1.1.1.1 255.255.255.255 13.0.0.1
ip route-static 2.2.2.2 255.255.255.255 23.0.0.1
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
<R3>
(4)检验
2.VLAN划分
实验要求:①pc1和pc3可以ping通pc5;pc2可以ping通pc4
②pc4可以ping通pc6
(1)SW1配置
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 access
port default vlan 10
#
interface Ethernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface Ethernet0/0/5
port link-type access
port default vlan 20
#
(2)SW2配置
interface Ethernet0/0/1
port link-type access
port default vlan 20
#
interface Ethernet0/0/2
port link-type access
port default vlan 10
#
interface Ethernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
(3)R1配置
#
interface GigabitEthernet0/0/0
ip address 192.168.2.254 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.3.1 255.255.255.0
#
interface NULL0
#
ip route-static 192.168.10.0 255.255.255.0 192.168.3.2
#
(4)R2配置
interface GigabitEthernet0/0/0
ip address 192.168.3.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.10.254 255.255.255.0
#
interface NULL0
#
ip route-static 192.168.2.0 255.255.255.0 192.168.3.1
(5)检验
3.单臂路由
实验要求:配置单臂路由使得全网互通
(1)R1配置
#
interface GigabitEthernet0/0/0.1
dot1q termination vid 10
ip address 192.168.1.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/0.2
dot1q termination vid 20
ip address 192.168.2.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/0.3
dot1q termination vid 30
ip address 192.168.3.254 255.255.255.0
arp broadcast enable
#
(2) SW配置
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface Ethernet0/0/2
port link-type access
port default vlan 10
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
#
interface Ethernet0/0/4
port link-type access
port default vlan 30
(3)检验