网络实验操作-VLAN

实验目的

了解VLAN的作用和配置。

基础实验

需求:所有PC在相同网段,但只有PC1和PC3可以互通,PC2和PC4可以互通

配置思路

将可以互通的PC放到相同的VLAN中即可。

配置过程

某一个switch的配置:

复制代码
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10 20
#
interface GigabitEthernet0/0/23
 port link-type access
 port default vlan 20
#
interface GigabitEthernet0/0/24
 port link-type access
 port default vlan 10

在另一个交换机上也进行类似配置,即可实现需求。

配置原理

连接PC机的接口配置为access类型,设置pvid。连接交换机的接口需承载vlan 10 20多个vlan, 配置为trunk类型,并设置允许通过的vlan。

VLAN互通实验

子接口实现

路由器子接口配置:

复制代码
#
interface GigabitEthernet0/0/0.10
 dot1q termination vid 10
 ip address 192.168.100.254 255.255.255.0 
 arp broadcast enable
#
interface GigabitEthernet0/0/0.20
 dot1q termination vid 20
 ip address 192.168.200.254 255.255.255.0 
 arp broadcast enable

arp广播从 V200R003C01 及之后版本默认已使能,但我用的ensp版本比较老还需要手动使能

交换机同基础实验配置。

vlanif实现

组网:LSW2作为核心交换机,LSW1作为接入交换机,两者通过三条链路互连,将三条链路作链路聚合。

核心交换机配置:

复制代码
#
interface Vlanif10
 ip address 192.168.100.254 255.255.255.0
#
interface Vlanif20
 ip address 192.168.200.254 255.255.255.0
#
interface MEth0/0/1
# 链路聚合
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 10 20
 mode lacp-static
 lacp preempt enable
 max active-linknumber 2
#
interface GigabitEthernet0/0/1
 eth-trunk 1
#
interface GigabitEthernet0/0/2
 eth-trunk 1
#
interface GigabitEthernet0/0/3
 eth-trunk 1

配置链路聚合只使用两条链路,且配置0/0/1和0/0/2优先级权重高优先使用这两条链路。

复制代码
[Huawei]display eth-trunk 1
Eth-Trunk1's state information is:
Local:
LAG ID: 1                   WorkingMode: STATIC                               
Preempt Delay Time: 30      Hash arithmetic: According to SIP-XOR-DIP         
System Priority: 32768      System ID: 4c1f-cc57-7134                         
Least Active-linknumber: 1  Max Active-linknumber: 2                          
Operate status: up          Number Of Up Port In Trunk: 2                     
--------------------------------------------------------------------------------
ActorPortName          Status   PortType PortPri PortNo PortKey PortState Weight
GigabitEthernet0/0/1   Selected 1GE      32768   2      305     10111100  1     
GigabitEthernet0/0/2   Selected 1GE      32768   3      305     10111100  1     
GigabitEthernet0/0/3   Unselect 1GE      32768   4      305     10100000  1     

Partner:
--------------------------------------------------------------------------------
ActorPortName          SysPri   SystemID        PortPri PortNo PortKey PortState
GigabitEthernet0/0/1   32768    4c1f-cc87-3fb6  100     2      305     10111100
GigabitEthernet0/0/2   32768    4c1f-cc87-3fb6  200     3      305     10111100
GigabitEthernet0/0/3   32768    4c1f-cc87-3fb6  32768   4      305     10100000

核心交换机路由表:

复制代码
[Huawei]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 6        Routes : 6        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
  192.168.100.0/24  Direct  0    0           D   192.168.100.254 Vlanif10
192.168.100.254/32  Direct  0    0           D   127.0.0.1       Vlanif10
  192.168.200.0/24  Direct  0    0           D   192.168.200.254 Vlanif20
192.168.200.254/32  Direct  0    0           D   127.0.0.1       Vlanif20

路由过程:主机(192.168.100.1)ping 192.168.200.1时,根据路由表找到下一跳接口为vlanif20, 发给对应的物理接口即聚合后的eth-trunk 1,发送到接入交换机然后传到目的主机。返回过程类似,不再详述。

总结

vlan的目的是划分逻辑子网,缩小广播域。通过基础实验可以了解,在业务需要时vlan之间的互通(三层)也可以实现,参考vlan互通实验。

相关推荐
东阳马生架构6 小时前
Netty基础—4.NIO的使用简介一
java·网络·netty
东阳马生架构8 小时前
Netty基础—3.基础网络协议二
网络·网络协议
Dontla9 小时前
Axios介绍(前端开发处理网络请求首选工具,基于Promise HTTP客户端,可以在浏览器和Node.js环境使用)(Axios库)
网络·http·node.js
狼头长啸李树身11 小时前
机器人交社保属于“无稽之谈”?
网络·机器人·媒体
yczykjyxgs12 小时前
边缘计算与 PCDN 的融合:未来网络架构新趋势
网络·人工智能·边缘计算
珹洺13 小时前
计算机网络:(一)详细讲解互联网概述与组成 (附带图谱更好对比理解)
服务器·开发语言·网络·数据库·后端·计算机网络·php
夜泉_ly14 小时前
项目日记 -云备份 -项目认识与环境搭建
linux·网络·c++
敲键盘的Q14 小时前
【eNSP实战】三层交换机使用ACL实现网络安全
网络
chen_song_15 小时前
WebRTC中音视频服务质量QoS之RTT衡量网络往返时延的加权平均RTT计算机制‌详解
网络·音视频·webrtc