华为设备配置vlan
<Huawei>
<Huawei>sys
<Huawei>system-view '进入系统视图'
Enter system view, return user view with Ctrl+Z.
[Huawei]undo inf en '关闭信息中心'
Info: Information center is disabled.
[Huawei]sys
[Huawei]sysname sw 1 '改名为sw 1'
[sw 1]int e0/0/1 '进入e0/0/1接口'
[sw 1-Ethernet0/0/1]po
[sw 1-Ethernet0/0/1]port l
[sw 1-Ethernet0/0/1]port link-t
[sw 1-Ethernet0/0/1]port link-type h
[sw 1-Ethernet0/0/1]port link-type hybrid '接口链路类型设置为hybrid'
[sw 1-Ethernet0/0/1]p h pvid vlan 1 '接口的pvid为vlan1'
[sw 1-Ethernet0/0/1]p h u v 1 2 'hybrid接口脱vlan1和2的标签'
[sw 1-Ethernet0/0/1]int e0/0/2 '进入e0/0/2接口'
[sw 1-Ethernet0/0/2]p l h '接口链路类型为hybrid'
[sw 1-Ethernet0/0/2]p h pvid vlan 1 'hybrid接口的pvid为1'
[sw 1-Ethernet0/0/2]p h u 1 2 'hybrid接口脱vlan1和2的标签'
^
Error:Ambiguous command found at '^' position.
[sw 1-Ethernet0/0/2]p h u v 1 2 'hybrid接口脱vlan1和2的标签'
[sw 1-Ethernet0/0/2]int e0/0/3 '进入e0/0/3接口'
[sw 1-Ethernet0/0/3]p l h '接口链路类型设为hybrid'
[sw 1-Ethernet0/0/3]p h pvid 10
^
Error:Ambiguous command found at '^' position.
[sw 1-Ethernet0/0/3]p h pvid v 10 'hybrid接口pvid为vlan10'
Error: The VLAN does not exist. '显示不存在,没有设置'
[sw 1-Ethernet0/0/3]q '返回上一层'
[sw 1]vlan b 10 2 3 'vlan 数据库内添加10 2 3'
Info: This operation may take a few seconds. Please wait for a moment...done.
'反馈需要一点时间,正在创建'
[sw 1]int e0/0/3 '此时再进e0/0/3'
[sw 1-Ethernet0/0/3]p l h '接口链路类型为hybrid'
[sw 1-Ethernet0/0/3]p h p 10
^
Error:Ambiguous command found at '^' position.
[sw 1-Ethernet0/0/3]p h p v 10 'hybrid接口pvid设为vlan10'
[sw 1-Ethernet0/0/3]p h u v 3 10
[sw 1-Ethernet0/0/3]int g 0/0/1
[sw 1-GigabitEthernet0/0/1]p l h
[sw 1-GigabitEthernet0/0/1]p h u v 1 2
[sw 1-GigabitEthernet0/0/1]p h t v3 10
^
Error:Ambiguous command found at '^' position.
[sw 1-GigabitEthernet0/0/1]p h t v 3 10
[sw 1-GigabitEthernet0/0/1]
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un inf en
Info: Information center is disabled.
[Huawei]sysyn sw 2
^
Error: Unrecognized command found at '^' position.
[Huawei]sysn sw 2
[sw 2]vlan bat 2 3 10
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw 2]int g0/0/1
[sw 2-GigabitEthernet0/0/1]p l h
[sw 2-GigabitEthernet0/0/1]p h pvid 1
^
Error:Ambiguous command found at '^' position.
[sw 2-GigabitEthernet0/0/1]p h pvid v 1
[sw 2-GigabitEthernet0/0/1]p h u v 1 2
[sw 2-GigabitEthernet0/0/1]p h t v 3 10
[sw 2-GigabitEthernet0/0/1]int e 0/0/1
[sw 2-Ethernet0/0/1]p l h
[sw 2-Ethernet0/0/1]p h pvid v 2
[sw 2-Ethernet0/0/1]p h u v 1 2
[sw 2-Ethernet0/0/1]int e0/0/2
[sw 2-Ethernet0/0/2]p l h
[sw 2-Ethernet0/0/2]p h pvid v 3
[sw 2-Ethernet0/0/2]p h u v 3 10
[sw 2-Ethernet0/0/2]
实验拓扑图:
实验目标:了解hybrid、trunk、access的配置以及应用
实验思路:
1.各个接口的ip地址整体配置,不要配错、有遗漏
2.该拓扑图中一共有三个网段,分别是192.168.10.0/24,192.168.20.0/24,11.0.0.0/30,所以需要给两台路由器各配置一条静态路由
3.重点在两台交换机,两台交换机分别有4个接口,trunk、access、hybrid链路都在其中,每个接口都要单独配置,在二层上又被分成了两个vlan,分别是vlan10和vlan20
实验配置过程:
1.先配置各个接口的IP地址
R1的接口IP地址:
The device is running!
<Huawei>system-view '进入系统视图'
Enter system view, return user view with Ctrl+Z. '反馈已进入'
[Huawei]un in en 'undo information-center enable,这里被简写,含义是关闭信心中心'
Info: Information center is disabled. '反馈已关闭'
[Huawei]sysn R1 '改名为R1'
[R1]int g0/0/0 '进入g0/0/0接口'
[R1-GigabitEthernet0/0/0]ip add 192.168.10.1 24 '配置ip地址为192.168.10.1/24'
[R1-GigabitEthernet0/0/0]un sh 'undo shutdown 启用'
Info: Interface GigabitEthernet0/0/0 is not shutdown. '反馈已启用'
[R1-GigabitEthernet0/0/0]int g0/0/1 '进入g0/0/1接口'
[R1-GigabitEthernet0/0/1]ip add 11.0.0.1 30 '配置ip地址为11.0.0.1/30'
[R1-GigabitEthernet0/0/1]un sh 'undo shutdown 启用'
Info: Interface GigabitEthernet0/0/1 is not shutdown. '反馈已启用'
[R1-GigabitEthernet0/0/1]dis this '查看此位置配置'
#
interface GigabitEthernet0/0/1
ip address 11.0.0.1 255.255.255.252
#
return
[R1-GigabitEthernet0/0/1]q '返回上一层'
R2的接口IP地址:
The device is running!
<Huawei>system-view '进入系统视图'
Enter system view, return user view with Ctrl+ Z. '反馈已进入'
[Huawei]un in en '关闭信息中心'
Info: Information center is disabled. '反馈关闭'
[Huawei]sysn R2 '改名为R2'
[R2]int g0/0/0 '进入g0/0/0接口'
[R2-GigabitEthernet0/0/0]ip add 192.168.20.1 24 '配置ip地址为192.168.20.1/24'
[R2-GigabitEthernet0/0/0]un sh '启用'
Info: Interface GigabitEthernet0/0/0 is not shutdown. '反馈已启用'
[R2-GigabitEthernet0/0/0]int g0/0/1 '进入g0/0/1接口'
[R2-GigabitEthernet0/0/1]ip add 11.0.0.2 30 '配置ip地址为11.0.0.2/30'
[R2-GigabitEthernet0/0/1]un sh '启用'
Info: Interface GigabitEthernet0/0/1 is not shutdown. '反馈已启用'
[R2-GigabitEthernet0/0/1]q '返回上一层'
PC1的ip地址、子网掩码、网关:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AoIePav0-1573226579739)(G:\GSY\Documents\typora图片\1573204854251.png)]
PC2的ip地址、子网掩码、网关:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6gilzlSh-1573226579739)(G:\GSY\Documents\typora图片\1573204865435.png)]
PC3的ip地址、子网掩码、网关:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AUfACrDa-1573226579739)(G:\GSY\Documents\typora图片\1573209138609.png)]
PC4的ip地址、子网掩码、网关:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-v0TtuUTu-1573226579739)(G:\GSY\Documents\typora图片\1573204884961.png)]
接口ip地址配置完毕,接下来配置路由器的静态路由
R1上通往192.168.20.0的静态路由
[R1]ip route-static 192.168.20.0 24 11.0.0.2
R2上通往192.168.10.0的静态路由
[R2]ip route-static 192.168.10.0 24 11.0.0.1
配置完检查一下
R1:
[R1]dis ip routing-table '查看路由表'
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
11.0.0.0/30 Direct 0 0 D 11.0.0.1 GigabitEthernet
0/0/1
11.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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.1 GigabitEthernet
0/0/0
192.168.10.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Static 60 0 RD 11.0.0.2 GigabitEthernet
0/0/1
R2:
[R2]dis ip routing-table '查看路由表'
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
11.0.0.0/30 Direct 0 0 D 11.0.0.2 GigabitEthernet
0/0/1
11.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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 Static 60 0 RD 11.0.0.1 GigabitEthernet
0/0/1
192.168.20.0/24 Direct 0 0 D 192.168.20.1 GigabitEthernet
0/0/0
192.168.20.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
路由配置完毕
接下来就是重头戏,交换机,需要先在交换机内创建vlan,把接口进行vlan划分,然后配置各个接口的链路模式
先配置LSW1
The device is running!
<Huawei>un in en '在用户视图中关掉信息中心'
Error: File can't be found "in". '反馈关不掉'
system-view ' 进入系统视图'
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en '关掉信息中心'
Info: Information center is disabled.
[Huawei]sysn sw 1 '改名为sw 1'
[sw 1]int e0/0/1 '进入e0/0/1接口'
[sw 1-Ethernet0/0/1]port l
[sw 1-Ethernet0/0/1]port link-t
[sw 1-Ethernet0/0/1]port link-type a
[sw 1-Ethernet0/0/1]port link-type access '接口创建链路类型为access'
[sw 1-Ethernet0/0/1]p
[sw 1-Ethernet0/0/1]port d
[sw 1-Ethernet0/0/1]port de
[sw 1-Ethernet0/0/1]port default v
[sw 1-Ethernet0/0/1]port default vlan 10 '把接口加入到vlan 10中'
Error: The VLAN does not exist. '反馈vlan 10 不存在,因为没有最先配置'
[sw 1-Ethernet0/0/1]q '这里退出配置'
[sw 1]vlan bat
[sw 1]vlan bate
[sw 1]vlan bat 10 20 '在数据库中创建vlan 10 和 vlan 20'
Info: This operation may take a few seconds. Please wait for a moment...done.
'这个操作可能需要几秒钟。请稍等……好了'
[sw 1]int e0/0/1 '进入e0/0/1几口,重新配置'
[sw 1-Ethernet0/0/1]por
[sw 1-Ethernet0/0/1]port l
[sw 1-Ethernet0/0/1]port link-t
[sw 1-Ethernet0/0/1]port link-type a
[sw 1-Ethernet0/0/1]port link-type access '接口链路类型设置为access'
[sw 1-Ethernet0/0/1]p
[sw 1-Ethernet0/0/1]port de
[sw 1-Ethernet0/0/1]port default vlan 10 '接口划分到vlan 10'
[sw 1-Ethernet0/0/1]un sh '启用'
Info: Interface Ethernet0/0/1 is not shutdown. '反馈已启用'
[sw 1-Ethernet0/0/1]int e0/0/2 '进入e0/0/2接口'
[sw 1-Ethernet0/0/2]po
[sw 1-Ethernet0/0/2]port l a
'port link-type access,这里是简写,接下来可以简写的我都会简写,体验一波'
[sw 1-Ethernet0/0/2]p d v 20 'port default vlan 20,接口划分到vlan 20'
[sw 1-Ethernet0/0/2]un sh '启用'
Info: Interface Ethernet0/0/2 is not shutdown. '反馈已启用'
[sw 1-Ethernet0/0/2]int g 0/0/1 '进入g0/01'
[sw 1-GigabitEthernet0/0/1]p l t
'port link-type trunk 接口链路类型设置为trunk'
[sw 1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
'所有vlan都被允许通过这个trunk接口'
[sw 1-GigabitEthernet0/0/1]int g 0/0/2 '进入g0/0/2接口'
[sw 1-GigabitEthernet0/0/2]p l h
'port link-type hybrid 接口链路类型设置为hybrid'
[sw 1-GigabitEthernet0/0/2]p h p v 10 'port hybrid pvid vlan 10 hybrid接口的pvid设置为vlan 10'
[sw 1-GigabitEthernet0/0/2]p h u v 10 20
'port hybrid untagged vlan 10 20,在此hybrid接口脱掉vlan 10和 vlan 20 的标签'
[sw 1-GigabitEthernet0/0/2]un sh '启用'
Info: Interface GigabitEthernet0/0/2 is not shutdown. '反馈已启用'
[sw 1-GigabitEthernet0/0/2]
然后配置LSW2的接口
The device is running!
<Huawei>system-view '进入系统视图'
Enter system view, return user view with Ctrl+Z. '反馈已启用'
[Huawei]un in en '关掉信息中心'
Info: Information center is disabled. '反馈已关闭'
[Huawei]sysn sw 2 '改名为sw 2'
[sw 2]int e 0/0/2 '进入e0/0/2接口'
[sw 2-Ethernet0/0/2]p l h '接口链路设置为hybrid'
[sw 2-Ethernet0/0/2]p h p v 20 '把接口划分到vlan20'
Error: The VLAN does not exist. '反馈当前vlan 20 不存在'
[sw 2-Ethernet0/0/2]q
[sw 2]vlan b 10 20 '创建vlan 10和vlan 20'
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw 2]int e 0/0/2 '重新进入e0/0/2接口'
[sw 2-Ethernet0/0/2]p h p v 20 '创建接口的pvid为vlan 20'
[sw 2-Ethernet0/0/2]p h u v 10 20 '配置接口的untagged为vlan 10 和 vlan20'
[sw 2-Ethernet0/0/2]un sh '启用'
Info: Interface Ethernet0/0/2 is not shutdown.
[sw 2-Ethernet0/0/2]int e 0/0/1 '进入e0/0/1接口'
[sw 2-Ethernet0/0/1]p l h '接口链路类型设置为hybrid'
[sw 2-Ethernet0/0/1]p h p v 10 'hybrid接口的pvid设为vlan10'
[sw 2-Ethernet0/0/1]p h u v 10 20 '配置接口的untagged为vlan 10 和 vlan20'
[sw 2-Ethernet0/0/1]un sh '启用'
Info: Interface Ethernet0/0/1 is not shutdown. '反馈已启用'
[sw 2-Ethernet0/0/1]int g 0/0/1 '进入g0/0/1接口'
[sw 2-GigabitEthernet0/0/1]p l t '接口链路类型设为trunk'
[sw 2-GigabitEthernet0/0/1]po
[sw 2-GigabitEthernet0/0/1]port t a v a '接口trunk允许所有vlan通过'
[sw 2-GigabitEthernet0/0/1]un sh '启用'
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[sw 2-GigabitEthernet0/0/1]int g 0/0/2 '进入g0/0/2接口'
[sw 2-GigabitEthernet0/0/2]p l h '接口链路类型设置为hybrid'
[sw 2-GigabitEthernet0/0/2]p h p v 20 '接口hybrid的pvid设为vlan20'
[sw 2-GigabitEthernet0/0/2]p h u v 10 20
'接口hybrid的untagged添加vlan10和vlan20'
[sw 2-GigabitEthernet0/0/2]un sh '启用'
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[sw 2-GigabitEthernet0/0/2]
配置完毕,接下来就可以ping实验
PC1pingPC2,ping通了
Welcome to use PC Simulator!
PC>ping 192.168.20.10
Ping 192.168.20.10: 32 data bytes, Press Ctrl_C to break
From 192.168.20.10: bytes=32 seq=1 ttl=126 time=219 ms
From 192.168.20.10: bytes=32 seq=2 ttl=126 time=125 ms
From 192.168.20.10: bytes=32 seq=3 ttl=126 time=109 ms
From 192.168.20.10: bytes=32 seq=4 ttl=126 time=125 ms
From 192.168.20.10: bytes=32 seq=5 ttl=126 time=94 ms
--- 192.168.20.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 94/134/219 ms
PC1pingPC3,ping通了
PC>ping 192.168.10.11
Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: bytes=32 seq=1 ttl=128 time=63 ms
From 192.168.10.11: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.10.11: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.10.11: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.10.11: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.10.11 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/56/63 ms
PC1pingPC4,主机不可达
PC>ping 192.168.10.12
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
From 192.168.10.10: Destination host unreachable
From 192.168.10.10: Destination host unreachable
From 192.168.10.10: Destination host unreachable
From 192.168.10.10: Destination host unreachable
From 192.168.10.10: Destination host unreachable
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC2ping PC3,ping通了
Welcome to use PC Simulator!
PC>ping 192.168.10.11
Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: bytes=32 seq=1 ttl=126 time=203 ms
From 192.168.10.11: bytes=32 seq=2 ttl=126 time=156 ms
From 192.168.10.11: bytes=32 seq=3 ttl=126 time=125 ms
From 192.168.10.11: bytes=32 seq=4 ttl=126 time=140 ms
From 192.168.10.11: bytes=32 seq=5 ttl=126 time=157 ms
--- 192.168.10.11 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 125/156/203 ms
PC2ping PC4,ping通了
PC>ping 192.168.10.12
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
From 192.168.10.12: bytes=32 seq=1 ttl=127 time=187 ms
From 192.168.10.12: bytes=32 seq=2 ttl=127 time=109 ms
From 192.168.10.12: bytes=32 seq=3 ttl=127 time=125 ms
From 192.168.10.12: bytes=32 seq=4 ttl=127 time=125 ms
From 192.168.10.12: bytes=32 seq=5 ttl=127 time=141 ms
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 109/137/187 ms
PC>ping 192.168.10.12 '再ping一次'
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
From 192.168.10.12: bytes=32 seq=1 ttl=127 time=110 ms
From 192.168.10.12: bytes=32 seq=2 ttl=127 time=125 ms
From 192.168.10.12: bytes=32 seq=3 ttl=127 time=109 ms
From 192.168.10.12: bytes=32 seq=4 ttl=127 time=125 ms
Request timeout! '连接超时'
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 109/117/125 ms
PC>ping 192.168.10.12 '再ping一次'
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.10.12: bytes=32 seq=2 ttl=127 time=141 ms
From 192.168.10.12: bytes=32 seq=3 ttl=127 time=109 ms
Request timeout!
Request timeout! '出现更多的超时'
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
2 packet(s) received
60.00% packet loss
round-trip min/avg/max = 0/125/141 ms
PC>ping 192.168.10.12 -t '长ping'
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
From 192.168.10.12: bytes=32 seq=3 ttl=127 time=141 ms
From 192.168.10.12: bytes=32 seq=4 ttl=127 time=94 ms
From 192.168.10.12: bytes=32 seq=5 ttl=127 time=140 ms
From 192.168.10.12: bytes=32 seq=6 ttl=127 time=172 ms
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout! '一直超时'
Request timeout!
Request timeout!
--- 192.168.10.12 ping statistics ---
23 packet(s) transmitted
4 packet(s) received
82.61% packet loss
round-trip min/avg/max = 0/136/172 ms
PC>ping 192.168.10.12
'这时过了一会,再次ping,还是超时,这里面有一个坑,大家可以动动脑筋'
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC3pingPC4,ping通了
Welcome to use PC Simulator!
PC>ping 192.168.10.12
Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break
From 192.168.10.12: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.10.12: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.10.12: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.10.12: bytes=32 seq=4 ttl=128 time<1 ms
From 192.168.10.12: bytes=32 seq=5 ttl=128 time=15 ms
--- 192.168.10.12 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 0/28/47 ms
简述流程:
PC1pingPC2:
PC1的ip地址为192.168.10.10,PC2的ip地址为192.168.20.10,不同网段,实现互联互通需要经过各自的网关,即通过R1和R2,
数据包过去的过程是:PC1(192.168.10.10)>LSW1(交换机)>R1(192.168.10.1)>R2(192.168.20.1)>LSW2(交换机)>LSW1(交换机)>PC2(192.168.20.10)
数据报回来的过程是:PC2(192.168.20.10)>LSW1(交换机)>LSW2(交换机)>R2(192.168.20.1)>R1(192.168.10.1)>LSW1(交换机)>PC1(192.168.10.10)
pc1发送数据包,经过lsw1交换机,sw1从e0/0/1接收到,会给数据打一个vlan10的标签,交换机查看数据包,发现需要发给网关,就会把数据包从g0/0/2接口发送出去
交换机g0/0/2的untag接口中有vlan 10,此时会把ping包的vlan10标签脱掉,发向R1,R1通过静态路由发到192.168.20.0网段,即R2的192.168.20.1接口处
R2的192.168.20.1是该网段的网关,接收到ping包会把ping包通过两台交换机发送给pc2
ping包从R2的g0/0/0接口发出,sw 2的g0/0/2接口接收,此时ping包不带vlan标签,sw2的g0/0/0会给ping包打一个vlan20的标签,转而发送到lsw1
lsw1的g0/0/1trunk接口接收到数据包,会从e0/0/2接口发出,e0/0/2接口的vlan是vlan20,跟ping包的vlan标签一致,可以通过,通过的时候会把vlan标签去掉
此时,ping包发送到pc2,接下来就是ping包返回的过程
ping包从PC2返回,经过lsw1的e0/0/2接口,e0/0/2接口是vlan20,ping包会被打上vlan20的标签,数据包会被传送到网关,从lsw1发送到R2,经过lsw2,从lsw2的e0/0/2接口出
lsw2 的e0/0/2接口是hybird模式,untag中有vlan 20,所以会把vlan20的标签拆掉,经过R2,转发到pc1(192.168.10.10)的网关,即R1的g0/0/0接口
R1把数据包转发给pc1,会经过交换机lsw1的g0/0/2接口,lsw1的g0/0/2接口是hybrid模式,接收到没有打标签的ping包会被打上vlan10的标签,ping包在交换即内经由e0/0/1接口发出到PC1(192.168.10.10),LSW1的e0/0/1接口的vlan为vlan10,允许ping包通过,通过的时候会把vlan标签拆掉,发送给pc1.此时ping包一来一回的过程就完成了,当然,其中也有没有目标地址的arp广播过程
PC3pingPC4流程:
pc3与pc4在同一网段,两者之间的互联互通不需要经过三层,数据在设备的流程为
数据包发送过去:PC3>LSW2>PC4
数据报返回:PC4>LSW2>PC3
数据包从pc3发出,经由lsw2的e0/0/1接口,即lsw2的e0/0/1接收到数据包,会给其打上一个vlan 10 的标签,然后经由lsw2的e0/0/2接口发送给pc4
lsw2的e0/0/2接口发送带有vlan10标签的数据包时,因为untag中有vlan10,所以会把vlan 10的标签拆掉,然后把数据包发送给PC4,此时,数据发送到目标主机的过程就已经完成了
pc将数据包返回,经过lsw2的e0/0/2接口,会被打上vlan20的标签,经过e0/0/1接口,因为untag中有vlan 20的记录,会把vlan 20标签拆掉,发送给pc3,此时,数据的返回便已完成
PC2pingPC4流程:
相当于不同网段的同一vlan进行通讯,需要经过三层设备去寻找目标网关,即
数据包发送过程:PC2>lsw1>lsw2>R2>R1>lsw1>lsw2>pc4
数据包返回过程:PC4>LSW2>LSW1>R1>R2>LSW2>LSW1>PC2
PC2发送数据包,经过lsw1的e0/0/2接口,会被打上vlan20的标签,经过lsw2,经由lsw2的g0/0/2接口发出,untag中有vlan 20,标签会被摘掉,通过R2去找到目标网段所在的网关,通过lsw1的g0/0/2接口,被打上vlan 10标签,经过lsw2,从e0/0/2接口发出,被摘掉vlan 10 标签,把数据包发送给pc4,此时,数据包发送过程结束
PC4返回数据包,经过lsw2的e0/0/2接口,被打上vlan 20标签,通过lsw的g0/0/2接口出,vlan 20 的标签被摘掉,通过R1去寻找到目标IP的网段所在的网关192.168.20.1,经过lsw2 的g0/0/2接口,被打上vlan 20的标签,从lsw1的e0/0/1接口发出,数据包的vlan 标签是vlan 20,允许通过,数据包返回到PC2,此时,数据包返回成功