大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
使用access接口
拓扑图:
LSW1:
<Huawei>system-view //进入系统视图
[Huawei]sysname LSW1 //修改设备名称
[LSW1]vlan batch 10 20 //创建VLAN10 20
[LSW1]int g0/0/2 //进入端口
[LSW1-GigabitEthernet0/0/2]port link-type access //设置access接口
[LSW1-GigabitEthernet0/0/2]port default vlan 10 //设置默认vlan为10
[LSW1-GigabitEthernet0/0/2]dis this //查看当前的配置
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
return
[LSW1-GigabitEthernet0/0/2]
[LSW1]int g0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type access
[LSW1-GigabitEthernet0/0/3]port default vlan 20
[LSW1-GigabitEthernet0/0/3]dis vlan //查看vlan
[LSW1-GigabitEthernet0/0/3]quit
<LSW1>save //保存
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y //Y
Now saving the current configuration to the slot 0.
May 27 2022 15:14:07-08:00 LSW1 %%01CFM/4/SAVE(l)[1]:The user chose Y when decid
ing whether to save the configuration to the device.
Save the configuration successfully.
[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 //允许vlan10通过
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 //允许vlan20通过
<LSW1>save
LSW2:
<Huawei>system-view //进入系统视图
[Huawei]sysname LSW2 //修改设备名称
[LSW2]vlan batch 10 20 //创建VLAN10 20
[LSW2]int g0/0/2 //进入端口
[LSW2-GigabitEthernet0/0/2]port link-type access //设置access接口
[LSW2-GigabitEthernet0/0/2]port default vlan 10 //设置默认vlan为10
[LSW2-GigabitEthernet0/0/2]dis this //查看当前的配置
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
return
[LSW2-GigabitEthernet0/0/2]
[LSW2]int g0/0/3
[LSW2-GigabitEthernet0/0/3]port link-type access
[LSW2-GigabitEthernet0/0/3]port default vlan 20
[LSW2-GigabitEthernet0/0/3]dis vlan //查看vlan
[LSW2-GigabitEthernet0/0/3]quit
<LSW2>save //保存
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y //Y
Now saving the current configuration to the slot 0.
May 27 2022 15:14:07-08:00 LSW1 %%01CFM/4/SAVE(l)[1]:The user chose Y when decid
ing whether to save the configuration to the device.
Save the configuration successfully.
[LSW2]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 //允许vlan10通过
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 //允许vlan20通过
<LSW2>save
测试pc1
PC>ping 192.168.10.3
Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break
From 192.168.10.3: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.10.3: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.10.3: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.10.3: bytes=32 seq=4 ttl=128 time=62 ms
From 192.168.10.3: bytes=32 seq=5 ttl=128 time=63 ms
--- 192.168.10.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/59/63 ms
PC>
测试pc2:
PC>ping 192.168.20.4
Ping 192.168.20.4: 32 data bytes, Press Ctrl_C to break
From 192.168.20.4: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.20.4: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.20.4: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.20.4: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.20.4: bytes=32 seq=5 ttl=128 time=62 ms
--- 192.168.20.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/59/63 ms
PC>
vlanif二层交换机拓展三层路由器
<Huawei>sys
[Huawei]sys sw1
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 10
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 10
[sw1-GigabitEthernet0/0/2]q
[sw1]int Vlanif 10
[sw1-Vlanif10]ip add 192.168.10.254 24
[sw1-Vlanif10]int Vlanif 20
[sw1-Vlanif20]ip add 192.168.20.254 24
[sw1-Vlanif20]dis ip int b //查看端口的情况
[sw1]dis 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.10.0/24 Direct 0 0 D 192.168.10.254 Vlanif10
192.168.10.254/32 Direct 0 0 D 127.0.0.1 Vlanif10
192.168.20.0/24 Direct 0 0 D 192.168.20.254 Vlanif20
192.168.20.254/32 Direct 0 0 D 127.0.0.1 Vlanif20
[sw1]
测试
[sw1]ping 192.168.20.2
PING 192.168.20.2: 56 data bytes, press CTRL_C to break
Reply from 192.168.20.2: bytes=56 Sequence=1 ttl=128 time=50 ms
Reply from 192.168.20.2: bytes=56 Sequence=2 ttl=128 time=40 ms
Reply from 192.168.20.2: bytes=56 Sequence=3 ttl=128 time=60 ms
Reply from 192.168.20.2: bytes=56 Sequence=4 ttl=128 time=30 ms
Reply from 192.168.20.2: bytes=56 Sequence=5 ttl=128 time=50 ms
--- 192.168.20.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/46/60 ms
[sw1]
hybrid接口
LSW1:
<Huawei>sys
[Huawei]sys LSW1
[LSW1]vlan batch 10 20 100
[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type hybrid
[LSW1-GigabitEthernet0/0/1]port hybrid pvid vlan 10 //设置pvid值为vlan10的标签
[LSW1-GigabitEthernet0/0/1]port hybrid untagged vlan 10 100 //剥离标签
[LSW1]int g0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type hybrid
[LSW1-GigabitEthernet0/0/2]port hybrid pvid vlan 20 //设置pvid值为vlan10的标签
[LSW1-GigabitEthernet0/0/2]port hybrid untagged vlan 20 100
[LSW1-GigabitEthernet0/0/2]dis vlan //查看所有vlan端口
[LSW1-GigabitEthernet0/0/2]int g0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type hybrid
[LSW1-GigabitEthernet0/0/3]port hybrid tagged vlan 10 20 100 //打标签,允许vlan10 20 100 通过
[LSW1-GigabitEthernet0/0/3]dis this //查看当前配置情况
LSW2:
<Huawei>sys
[Huawei]sys LSW2
[LSW2]vlan ba 10 20 100
[LSW2-GigabitEthernet0/0/3]port link-type hybrid
[LSW2-GigabitEthernet0/0/3]port hybrid tagged vlan 10 20 100 //打标签
[LSW2-GigabitEthernet0/0/3]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type hybrid
[LSW2-GigabitEthernet0/0/1]port hybrid pvid vlan 100 //设置pvid
[LSW2-GigabitEthernet0/0/1]port hybrid untagged vlan 10 20 100 //剥离标签
[LSW2-GigabitEthernet0/0/1]dis vlan //检查
测试:PC1 ping PC2
测试PC1跟PC3是否相通:
本文章纯属个人笔记,如有不当请指正!
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/194071.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...