vlanif实现不同vlan之间的通信

【实验目的】

1.实现网络隔离:通过将不同的设备连接到不同的VLAN,可以将它们隔离在不同的虚拟网络中,提高网络的安全性和管理灵活性。

2.提供逻辑分组:将不同功能的设备分组到不同的VLAN,可以提供更好的逻辑分组,方便管理和配置。

3.减少广播风暴:每个VLAN都有自己的广播域,可以减少广播报文在整个网络中传播,提高网络性能和带宽利用率。

4.提供灵活的网络架构:通过使用vlanif接口,可以根据需要进行VLAN之间的通信配置,实现更灵活的网络架构。

【实验拓扑】

【需求分析】

  1. PC1和PC2属于不同的vlan。
  2. 实现PC1和PC2之间的通信。

【实现方法】

1.在三层交换机上配置VLANIF接口来实现VLAN间路由。

2.如果网络上有多个VLAN,则需要给每个VLAN配置一个VLANIF接口,并给每个VLANIF接口配置一个IP地址。

3.用户设置的缺省网关就是三层交换机中VLANIF接口的IP地址。

【PC配置】

【交换机配置】

【SW1配置】-------------------------------------------------------------------------------
Please press enter to start cmd line!

<Huawei>sys

Error: Unrecognized command found at '^' position.
[Huawei]sys SW1
[SW1]
Oct  9 2023 10:40:21-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 batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]
Oct  9 2023 10:44:31-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]int e 0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]
Oct  9 2023 10:47:41-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]port default vlan 3
[SW1-Ethernet0/0/1]
Oct  9 2023 10:49:51-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.
[SW1-Ethernet0/0/1]port default vlan 2

[SW1-Ethernet0/0/1]
Oct  9 2023 10:50:21-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 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW1-Ethernet0/0/1]dis this
#
interface Ethernet0/0/1
 port link-type access
 port default vlan 2
#
return
[SW1-Ethernet0/0/1]int e0/0/3
[SW1-Ethernet0/0/3]port link-type trunk
[SW1-Ethernet0/0/3]
[SW1-Ethernet0/0/3]
Oct  9 2023 10:54:21-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.

[SW1-Ethernet0/0/3]port trunk allow-pass vlan 2 3
[SW1-Ethernet0/0/3]q
[SW1]
Oct  9 2023 10:54:51-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]int vlanif2
[SW1-Vlanif2]
Oct  9 2023 10:55:00-08:00 SW1 %%01IFNET/4/IF_STATE(l)[53]:Interface Vlanif2 has
 turned into UP state.
[SW1-Vlanif2]ip add 10.1.1.254 24
[SW1-Vlanif2]
Oct  9 2023 10:55:13-08:00 SW1 %%01IFNET/4/LINK_STATE(l)[54]:The line protocol I
P on the interface Vlanif2 has entered the UP state.
[SW1-Vlanif2]
Oct  9 2023 10:55:21-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 11, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-Vlanif2]int vlanif3
[SW1-Vlanif3]
Oct  9 2023 10:56:33-08:00 SW1 %%01IFNET/4/IF_STATE(l)[55]:Interface Vlanif3 has
 turned into UP state.

[SW1-Vlanif3]ip add 10.2.2.254 24
[SW1-Vlanif3]
Oct  9 2023 10:56:50-08:00 SW1 %%01IFNET/4/LINK_STATE(l)[56]:The line protocol I
P on the interface Vlanif3 has entered the UP state.
Oct  9 2023 10:56:51-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 12, the 
change loop count is 0, and the maximum number of records is 4095.
[SW1-Vlanif3]
Oct  9 2023 11:07:56-08:00 SW1 %%01ARP/4/ARP_DUPLICATE_IPADDR(l)[57]:Received an
 ARP packet with a duplicate IP address from the interface. (IpAddress=10.1.1.25
4, InterfaceName=Vlanif2, MacAddress=4c1f-cc89-5cbd)
Oct  9 2023 11:08:11-08:00 SW1 %%01ARP/4/ARP_DUPLICATE_IPADDR(l)[58]:Received an
 ARP packet with a duplicate IP address from the interface. (IpAddress=10.2.2.25
4, InterfaceName=Vlanif3, MacAddress=4c1f-cc89-5cbd) User interface con0 is available

Please Press ENTER.

【SW2配置】-------------------------------------------------------------------------------
The device is running!

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW2
[SW2]
Oct  9 2023 10:44:36-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.
[SW2]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]
Oct  9 2023 10:44:46-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]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]
Oct  9 2023 10:47:26-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.
[SW2]int e0/0/2
[SW2-Ethernet0/0/2]port link-type access
[SW2-Ethernet0/0/2]
Oct  9 2023 10:49:36-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. User interface con0 is available

[SW2]int e0/0/2
[SW2-Ethernet0/0/2]port default vlan 3
[SW2-Ethernet0/0/2]
Oct  9 2023 11:05:47-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 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-Ethernet0/0/2]int e0/0/1
[SW2-Ethernet0/0/1]port link-type trunk
[SW2-Ethernet0/0/1]
Oct  9 2023 11:06: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 9, the c
hange loop count is 0, and the maximum number of records is 4095.

[SW2-Ethernet0/0/1]port trunk allow-pass vlan 2 3
[SW2-Ethernet0/0/1]q
[SW2]int vlanif 2
[SW2-Vlanif2]
Oct  9 2023 11:07:37-08:00 SW2 %%01IFNET/4/IF_STATE(l)[0]:Interface Vlanif2 has 
turned into UP state.
Oct  9 2023 11:07:37-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 10, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2-Vlanif2]ip add 10.1.1.254 24
[SW2-Vlanif2]
Oct  9 2023 11:07:56-08:00 SW2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
 on the interface Vlanif2 has entered the UP state.
Oct  9 2023 11:07:57-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 11, the 
change loop count is 0, and the maximum number of records is 4095.
[SW2-Vlanif2]int vlanif3
[SW2-Vlanif3]
Oct  9 2023 11:08:01-08:00 SW2 %%01IFNET/4/IF_STATE(l)[2]:Interface Vlanif3 has 
turned into UP state.
[SW2-Vlanif3]ip add 10.2.2.254 24
[SW2-Vlanif3]
Oct  9 2023 11:08:11-08:00 SW2 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
 on the interface Vlanif3 has entered the UP state.
[SW2-Vlanif3]
Oct  9 2023 11:08:17-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 12, the 
change loop count is 0, and the maximum number of records is 4095.
Oct  9 2023 11:08:27-08:00 SW2 %%01ARP/4/ARP_DUPLICATE_IPADDR(l)[4]:Received an 
ARP packet with a duplicate IP address from the interface. (IpAddress=10.1.1.254
, InterfaceName=Vlanif2, MacAddress=4c1f-ccfc-7a54)
Oct  9 2023 11:09:07-08:00 SW2 %%01ARP/4/ARP_DUPLICATE_IPADDR(l)[5]:Received an 
ARP packet with a duplicate IP address from the interface. (IpAddress=10.2.2.254
, InterfaceName=Vlanif3, MacAddress=4c1f-ccfc-7a54)

【连通性测试】

【实验小结】

在使用vlanif实现不同vlan之间通信的实验过程中,需要注意以下几点:

1. 首先需要在交换机上进行vlan划分,并将对应端口加入到相应的vlan中。

2. 然后在路由器上创建不同的vlanif,并设置对应的IP地址。

3. 接着需要在路由器上配置不同vlan之间的路由。

4. 最后在主机上配置对应vlan的IP地址,即可实现不同vlan之间的通信。

需要注意的是,在配置过程中还需注意防火墙等其他网络配置,避免影响通信效果。

【总结】
1.使用vlanif实现不同vlan之间通信的步骤
①配置pc的ip、掩码、网关;
②交换机之间配置为trunk接口,设置可以通过的vlan;
③设置连接pc的接口的类型为access和vlanid;
④在交换机上配置vlanif的ip
2.上述步骤对应的配置命令
①双击pc配置
②port link-type trunk
 port trunk allow-pass vlan 2 3
③port link-type access
 port default vlan 2
④int vlanif2
 ip add 10.1.1.254 24

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值