通过VLAN实现主机之间的互通

配置了两台交换机SW1和SW2的VLAN10和20,并将接口分配到相应VLAN。在SW1的e0/0/1、e0/0/2和e0/0/4接口上配置了VLAN,SW2的e0/0/2和e0/0/3接口也进行了类似配置。同时,配置了SW1的e0/0/3和SW2的e0/0/1为trunk接口,允许所有VLAN通过。路由器R1和R2的接口分别配置了IP地址,并设置了静态路由,实现了PC1、PC3、PC2和PC4的互通。

在这里插入图片描述
在这里插入图片描述
创建SW1 SW2的VLAN 10 20

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW1
[SW1]
Apr  6 2021 20:08:20-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1]vlan ba	
[SW1]vlan batch 10 20

<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW2
[SW2]vlan b
Apr  6 2021 20:10:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.a	
[SW2]vlan batch 10 20

配置 SW1中接口e0/0/1 e0/0/2 e0/0/4的VLan

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW1
[SW1]
Apr  6 2021 20:08:20-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1]vlan ba	
[SW1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]
Apr  6 2021 20:08:40-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1]
[SW1]
[SW1]inter	
[SW1]interface e0/0/1
[SW1-Ethernet0/0/1]p l a
[SW1-Ethernet0/0/1]p d v 10
Apr  6 2021 20:13:10-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-Ethernet0/0/1]
Apr  6 2021 20:13:20-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 7, the c
hange loop count is 0, and the maximum number of records is 4095.q
[SW1]inter	
[SW1]interface e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]
Apr  6 2021 20:13:50-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.q
[SW1]inter	
[SW1]interface e0/0/4
[SW1-Ethernet0/0/4]p l a
[SW1-Ethernet0/0/4]
Apr  6 2021 20:14:10-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 10, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-Ethernet0/0/4]p d v 10

配置 SW2中接口e0/0/3 e0/0/2 的VLan

The device is running!

<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW2
[SW2]vlan b
Apr  6 2021 20:10:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.a	
[SW2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]
Apr  6 2021 20:10:41-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2]
[SW2]inter	
[SW2]interface e0/0/2
[SW2-Ethernet0/0/2]p l a 
[SW2-Ethernet0/0/2]p d v
Apr  6 2021 20:17:01-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.20
                   ^
Error:Ambiguous command found at '^' position.
[SW2-Ethernet0/0/2]p d v 20
[SW2-Ethernet0/0/2]q
[SW2]inter	
[SW2]interface e0/0/
Apr  6 2021 20:17:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 7, the c
hange loop count is 0, and the maximum number of records is 4095.3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 10
[SW2-Ethernet0/0/3]q
[SW2]
Apr  6 2021 20:17:41-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.

配置SW1和SW2的TRUNK

SW1]inter	
[SW1]interface e0/0/3
[SW1-Ethernet0/0/3]p l t
[SW1-Ethernet0/0/3]
Apr  6 2021 21:53:27-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-Ethernet0/0/3]p t a v a

[SW2]inter	
[SW2]interface e0/0/1
[SW2-Ethernet0/0/1]p l t
[SW2-Ethernet0/0/1]
Apr  6 2021 21:55:07-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 5, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-Ethernet0/0/1]
[SW2-Ethernet0/0/1]p t a v a

配置R1的路由

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
Apr  6 2021 14:13:18-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 

[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 24
Apr  6 2021 14:13:54-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[R1-GigabitEthernet0/0/1]ip route-static 192.168.10.0 24 12.0.0.2

配置R2的路由

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
Apr  6 2021 14:16:22-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 

[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.10.254 24
Apr  6 2021 14:16:47-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[R2-GigabitEthernet0/0/1]q
[R2]ip route-static 192.168.2.0 24 12.0.0.1

PC1和PC3可以ping通PC5
在这里插入图片描述
在这里插入图片描述
PC2可以ping通PC4
在这里插入图片描述
PC4可以ping通PC6
在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值