VLAN介绍和工业SIP电话配置

VLAN 概述

什么是 VLAN

以太网是基于CSMA/CD(载波监听多路访问/冲突检测)的共享介质网络技术。大量主机接入会引发严重冲突、广播风暴、性能下降及网络中断问题。交换机虽能减少冲突,但无法隔离广播流量。

VLAN(虚拟局域网)技术可将物理局域网划分为多个逻辑广播域,以此解决上述问题。同一VLAN内的设备可如同在同一局域网内通信;不同VLAN之间无法直接互通,从而限制广播范围。

VLAN 互联逻辑图

VLAN不受物理位置限制。设备可接入同一交换机、跨交换机部署,或跨越路由器,同时归属同一个VLAN。

VLAN 优势:

  1. 限制广播域范围,降低路由负载,减少延迟,节约带宽并提升整体网络性能。

  2. 提升安全性:VLAN 之间实现二层隔离,跨VLAN通信需要三层路由转发。

  3. 灵活组建虚拟工作组:无需改动物理布线,即可对用户进行逻辑分组。

VLAN 工作原理

为区分VLAN数据帧,会在数据链路层(二层)的以太网头部添加VLAN标签。

IEEE 于1999年通过802.1Q协议标准化VLAN标签机制,定义了为以太网数据包添加VLAN标识的通用标准。

802.1Q 会在源MAC地址与以太网类型字段之间插入4字节标签:

  • 2 字节:TPID(标签协议标识符)

  • 2 字节:TCI(标签控制信息)

TCI 包含PCP(优先级代码点)、CFI(标准格式指示器)与 VID(VLAN 编号)。

传统以太网帧格式

图 1-2 传统以太网帧格式

VLAN 标签结构

图 1-3 VLAN 标签字段

VLAN 标签字段说明:

  1. TPID:16位,标识802.1Q标签,默认值 0x8100。

  2. 优先级:3位,对应 802.1p 服务等级(CoS)。

  3. CFI:1位,MAC地址格式标识;0 代表标准格式,默认值为 0。

  4. VLAN 编号:12位,用于唯一标识VLAN;有效范围1–4094(0 和 4095 为保留值)。

注意:对于双层标签(QinQ)帧,交换机仅处理外层标签,内层标签将被视为负载数据。

VLAN 应用场景

2.3.1 LLDP 简介

LLDP(链路层发现协议)可让局域网内设备互相发布并获取邻居设备信息。相关数据存储在MIB库中,可通过SNMP协议查询(RFC 2922)。

LLDP 采用TLV(类型/长度/值)结构承载设备信息,多个TLV组合构成LLDPDU(LLDP数据单元)。

类型长度取值
7 位9 位0-511 字节

图 1-4 TLV 结构

LLDP-MED(媒体终端发现协议)是面向语音设备的LLDP扩展协议,具备以下能力:

  • 设备能力发现

  • 语音VLAN配置

  • PoE 供电管理

  • 设备资产盘点

  • 紧急呼叫位置识别

注意:同一端口无法同时启用 LLDP 与 LLDP-MED。

IP 电话的 LLDP 功能

启用LLDP后,电话会周期性向外发送设备信息,并监听交换机报文。当应用类型为语音时,设备可自动从交换机获取语音VLAN编号,更新配置并重启生效。

LLDP 网页配置步骤

  1. 使用账号 admin/admin 登录网页管理界面。

  2. 进入 网络 → 高级设置

  3. 开启 LLDP 功能。

  4. 设置报文发送间隔(1–3600秒)。

  5. 点击应用,重启电话。

LLDP 网页配置界面

图 1-5 LLDP 配置界面

启用 LLDP 后,电话将执行以下操作:

  • 周期性发送组播 LLDP 报文。

  • 通过WAN、LAN端口接收LLDP报文。

  • 支持MAC/PHY层配置管理。

  • 通过网络策略TLV获取VLAN配置(优先覆盖手动设置)。

电话发送的 LLDP 报文电话接收的 LLDP 报文获取VLAN后发送的LLDP报文

2.3.2 CDP 简介

CDP(思科发现协议)是思科私有二层协议,用于邻接设备发现。

IP 电话的 CDP 功能
电话会广播自身信息,并接收交换机的CDP报文,自动学习语音VLAN编号,更新配置后重启设备。

CDP 网页配置步骤

  1. 使用 admin/admin 账号登录。

  2. 进入 网络 → 高级设置

  3. 启用 CDP。

  4. 设置消息发送间隔(1–3600秒)。

  5. 点击应用

CDP 配置界面

图 1-6 CDP 配置界面

电话发送的 CDP 报文电话接收的 CDP 报文获取VLAN后发送的CDP报文

2.3.3 DHCP 自动获取 VLAN

设备支持基于DHCP的VLAN发现,默认通过DHCP 132号选项获取VLAN编号,最多支持5项自定义DHCP选项。

DHCP VLAN 网页配置步骤

  1. 使用 admin/admin 登录。

  2. 进入 网络 → 高级设置

  3. 开启 DHCP VLAN 功能。

  4. 填写DHCP选项编号(例如 132)。

  5. 点击应用

DHCP VLAN 配置界面

图 1-7 DHCP VLAN 配置界面

运行流程

  1. 电话广播发送 DHCP 发现报文。

  2. 服务器回复报文并携带132号选项(VLAN编号)。

  3. 电话释放当前IP地址,使用获取到的VLAN编号标记所有流量,重新发起DHCP请求。

电话发送DHCP发现报文电话接收DHCP分配报文

2.3.4 手动配置 VLAN

VLAN 默认关闭,可分别为WAN(外网)端口与LAN(电脑)端口独立配置VLAN编号及802.1p优先级(取值0–7,数值越大优先级越高)。

WAN 端口 VLAN 配置(网页端)

  1. 使用 admin/admin 登录。

  2. 进入 网络 → 高级设置

  3. 启用 VLAN。

  4. 设置 WAN VLAN 编号(1–4094)。

  5. 设置优先级(0–7)。

  6. 点击应用

WAN VLAN 配置界面

图 1-8 WAN VLAN 配置

LAN 端口 VLAN 配置(网页端)

  1. 使用 admin/admin 登录。

  2. 进入 网络 → 高级设置

  3. 配置 LAN VLAN 模式与编号。

  4. 设置优先级。

  5. 点击应用

LAN VLAN 配置界面

图 1-9 LAN VLAN 配置

电话液晶屏 VLAN 配置

菜单 → 高级设置(密码:123)→ 网络 → 服务质量&Vlan → 外网VLAN / 内网VLAN

WAN VLAN 液晶界面LAN VLAN 液晶界面

配置验证
抓取数据包,校验SIP与RTP报文内的802.1Q标签、VLAN编号及802.1p优先级。

抓包截图抓包截图

交换机 VLAN 配置

Trunk、Access、Hybrid、标签/无标签概念说明

以太网交换机端口支持三种工作模式:

  • 接入模式(Access):仅归属单个VLAN,用于电脑等终端设备。

  • 中继模式(Trunk):承载多个VLAN流量,用于交换机互联。

  • 混合模式(Hybrid):转发多VLAN数据,支持自定义无标签出端口规则。

核心规则

  • 带标签(Tagged):报文发送时保留802.1Q VLAN标签。

  • 无标签(Untagged):交换机转发前移除VLAN标签。

  • PVID(端口VLAN编号):为无标签入站报文分配的默认VLAN。

端口类型入站处理出站处理
接收无标签报文接收带标签报文
Access添加PVID标签VLAN不匹配则丢弃移除标签并转发
Trunk允许时添加PVID标签仅放行允许的VLAN仅PVID对应VLAN移除标签
Hybrid允许时添加PVID标签仅放行允许的VLAN按端口配置保留/移除标签

Cisco 2960 交换机 VLAN 配置

以太网 VLAN 默认参数

参数默认值取值范围
VLAN 编号11–4094
VLAN 名称VLANxxxx
MTU15001500–18190
状态启用启用/暂停

创建/修改 VLAN

步骤命令作用
1configure terminal进入全局配置模式
2vlan 创建或编辑VLAN
3name 自定义VLAN名称
4end退回特权模式
5show vlan校验配置
6copy running-config startup-config保存配置

删除 VLAN

步骤命令作用
1configure terminal进入全局配置模式
2no vlan 删除指定VLAN
3end退出配置模式
4show vlan brief验证删除结果

端口划入VLAN(接入端口)

步骤命令作用
1configure terminal进入全局配置
2interface 选择目标端口
3switchport mode access设置为接入端口
4switchport access vlan 为端口分配VLAN
5end退出配置

配置中继端口(Trunk)

步骤命令作用
1configure terminal进入全局配置
2interface 选择端口
3switchport mode trunk设置为中继端口
4switchport trunk native vlan 配置本征VLAN
5end退出配置

Trunk 端口放行VLAN

switchport trunk allowed vlan { add | all | except | remove }

配置本征VLAN

switchport trunk native vlan

适用设备

Cisco 2960 系列交换机

目录
客服 电话
We use cookie to improve your online experience. By continuing to browse this website, you agree to our use of cookie.

Cookies

This Cookie Policy explains how we use cookies and similar technologies when you access or use our website and related services. Please read this Policy together with our Terms and Conditions and Privacy Policy so that you understand how we collect, use, and protect information.

By continuing to access or use our Services, you acknowledge that cookies and similar technologies may be used as described in this Policy, subject to applicable law and your available choices.

Updates to This Cookie Policy

We may revise this Cookie Policy from time to time to reflect changes in legal requirements, technology, or our business practices. When we make updates, the revised version will be posted on this page and will become effective from the date of publication unless otherwise required by law.

Where required, we will provide additional notice or request your consent before applying material changes that affect your rights or choices.

What Are Cookies?

Cookies are small text files placed on your device when you visit a website or interact with certain online content. They help websites recognize your browser or device, remember your preferences, support essential functionality, and improve the overall user experience.

In this Cookie Policy, the term “cookies” also includes similar technologies such as pixels, tags, web beacons, and other tracking tools that perform comparable functions.

Why We Use Cookies

We use cookies to help our website function properly, remember user preferences, enhance website performance, understand how visitors interact with our pages, and support security, analytics, and marketing activities where permitted by law.

We use cookies to keep our website functional, secure, efficient, and more relevant to your browsing experience.

Categories of Cookies We Use

Strictly Necessary Cookies

These cookies are essential for the operation of the website and cannot be disabled in our systems where they are required to provide the service you request. They are typically set in response to actions such as setting privacy preferences, signing in, or submitting forms.

Without these cookies, certain parts of the website may not function correctly.

Functional Cookies

Functional cookies enable enhanced features and personalization, such as remembering your preferences, language settings, or previously selected options. These cookies may be set by us or by third-party providers whose services are integrated into our website.

If you disable these cookies, some services or features may not work as intended.

Performance and Analytics Cookies

These cookies help us understand how visitors use our website by collecting information such as traffic sources, page visits, navigation behavior, and general interaction patterns. In many cases, this information is aggregated and does not directly identify individual users.

We use this information to improve website performance, usability, and content relevance.

Targeting and Advertising Cookies

These cookies may be placed by our advertising or marketing partners to help deliver more relevant ads and measure the effectiveness of campaigns. They may use information about your browsing activity across different websites and services to build a profile of your interests.

These cookies generally do not store directly identifying personal information, but they may identify your browser or device.

First-Party and Third-Party Cookies

Some cookies are set directly by our website and are referred to as first-party cookies. Other cookies are set by third-party services, such as analytics providers, embedded content providers, or advertising partners, and are referred to as third-party cookies.

Third-party providers may use their own cookies in accordance with their own privacy and cookie policies.

Information Collected Through Cookies

Depending on the type of cookie used, the information collected may include browser type, device type, IP address, referring website, pages viewed, time spent on pages, clickstream behavior, and general usage patterns.

This information helps us maintain the website, improve performance, enhance security, and provide a better user experience.

Your Cookie Choices

You can control or disable cookies through your browser settings and, where available, through our cookie consent or preference management tools. Depending on your location, you may also have the right to accept or reject certain categories of cookies, especially those used for analytics, personalization, or advertising purposes.

Please note that blocking or deleting certain cookies may affect the availability, functionality, or performance of some parts of the website.

Restricting cookies may limit certain features and reduce the quality of your experience on the website.

Cookies in Mobile Applications

Where our mobile applications use cookie-like technologies, they are generally limited to those required for core functionality, security, and service delivery. Disabling these essential technologies may affect the normal operation of the application.

We do not use essential mobile application cookies to store unnecessary personal information.

How to Manage Cookies

Most web browsers allow you to manage cookies through browser settings. You can usually choose to block, delete, or receive alerts before cookies are stored. Because browser controls vary, please refer to your browser provider’s support documentation for details on how to manage cookie settings.

Contact Us

If you have any questions about this Cookie Policy or our use of cookies and similar technologies, please contact us at support@becke.cc .