eNSP网络仿真——VLAN间通信(同网段,不同网段)

eNSP网络仿真——VLAN间通信(同网段,不同网段)

VLAN间通信的第一种情况:各VLAN 处在同一网段下。

实验拓扑如图:
eNSP网络仿真——VLAN间通信(同网段,不同网段)_第1张图片实验配置如下:

设备 接口 IP地址 子网掩码 网关
PC-1 Ethernet 0/0/1 198.168.1.1 255.255.255.0 192.168.1.254
PC-2 Ethernet 0/0/1 198.168.1.2 255.255.255.0 192.168.1.254
PC-3 Ethernet 0/0/1 198.168.2.1 255.255.255.0 192.168.2.254
LSW VLANIF 10 192.168.1.254 255.255.255.0 N/A
LSW VLANIF 20 192.168.2.254 255.255.255.0 N/A

配置过程:
(1)创建VLAN和修改链路类型

sys	
system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en  //全拼undo info-center enable,缺省情况下信息中心开启会提示相关警告。关闭就看不到乱七八糟的警告了
Info: Information center is disabled.
[Huawei]vlan 10
[Huawei-vlan10]vlan 20
[Huawei-vlan20]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]po	
[Huawei-GigabitEthernet0/0/1]port l	
[Huawei-GigabitEthernet0/0/1]port link-t	
[Huawei-GigabitEthernet0/0/1]port link-type a	
[Huawei-GigabitEthernet0/0/1]port link-type access 
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]q
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type access
[Huawei-GigabitEthernet0/0/3]q

(2)配置VLANIF接口

[Huawei]interface Vlanif 10
[Huawei-Vlanif10]ip a	
[Huawei-Vlanif10]ip address 192.168.1.254 24
[Huawei-Vlanif10]q
[Huawei]interface Vlanif 20
[Huawei-Vlanif20]ip address 192.168.2.254 24
[Huawei-Vlanif20]q

(3)查看接口状态

[Huawei]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 3
The number of interface that is UP in Protocol is 1
The number of interface that is DOWN in Protocol is 4

Interface                         IP Address/Mask      Physical   Protocol  
MEth0/0/1                         unassigned           down       down      
NULL0                             unassigned           up         up(s)     
Vlanif1                           unassigned           up         down      
Vlanif10                          192.168.1.254/24     down       down      //可以看出接口是down掉的,在配置VLANIF的IP时别忘了加一句 no shut,我就给忘了
Vlanif20                          192.168.2.254/24     down       down      

(4)配置端口默认VLAN

[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port de	
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port default vlan 10
[Huawei-GigabitEthernet0/0/2]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port default vlan 20
[Huawei-GigabitEthernet0/0/3]q

(5)验证

PC>ping 192.168.2.1

Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
From 192.168.2.1: bytes=32 seq=1 ttl=127 time=78 ms
From 192.168.2.1: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.2.1: bytes=32 seq=3 ttl=127 time=47 ms
From 192.168.2.1: bytes=32 seq=4 ttl=127 time=31 ms
From 192.168.2.1: bytes=32 seq=5 ttl=127 time=31 ms

--- 192.168.2.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/46/78 ms

实验结果显示,处于相同网段下不同VLAN的PC-1和PC-3可以ping通。

关于VLANIF:
华为的文档是这样描述的:VLANIF接口是网络层接口,可以配置IP地址,创建VLANIF接口前要先创建对应的VLAN。借助VLANIF接口,设备就能与其它网络层的设备互相通信。
通俗的讲VLANIF是逻辑端口,这个接口地址作为vlan下面用户的网关。

VLAN间通信的第二种情况:各VLAN 处在不同网段下(单臂路由)。

实验拓扑如图:
eNSP网络仿真——VLAN间通信(同网段,不同网段)_第2张图片
PC1配置:
eNSP网络仿真——VLAN间通信(同网段,不同网段)_第3张图片
PC2配置:

eNSP网络仿真——VLAN间通信(同网段,不同网段)_第4张图片

交换机配置:

[Huawei]int e0/0/8
[Huawei-Ethernet0/0/8]port link-type access 
[Huawei-Ethernet0/0/8]port default vlan 35
[Huawei-Ethernet0/0/8]int e0/0/10
[Huawei-Ethernet0/0/10]port link-type access
[Huawei-Ethernet0/0/10]port default vlan 36
[Huawei-Ethernet0/0/10]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk 
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all 
[Huawei-GigabitEthernet0/0/1]

路由器配置:

sys	
system-view 
[Huawei]un in en
Info: Information center is disabled.
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]ip a	
[Huawei-GigabitEthernet0/0/0.1]ip address 35.35.35.254 24
[Huawei-GigabitEthernet0/0/0.1]dot1q termination vid 35    //dot1q就是“点1q”,该子接口在收到带有vlan tag 35的报文时,将剥离tag进行三层转发,该子接口在发送报文时,会打上vlan为35的tag
[Huawei-GigabitEthernet0/0/0.1]arp broadcast enable  //子接口隔离了广播域,所以开启arp
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]ip address 35.35.36.254 24
[Huawei-GigabitEthernet0/0/0.2]dot1q termination vid 36
[Huawei-GigabitEthernet0/0/0.2]arp broadcast enable

测试两台主机可达
eNSP网络仿真——VLAN间通信(同网段,不同网段)_第5张图片```

查看一下交换机的mac表
eNSP网络仿真——VLAN间通信(同网段,不同网段)_第6张图片

实验结果显示,处于不同网段下不同VLAN的PC-1和PC-2可以ping通。

** Mission all over**

你可能感兴趣的:(计算机网络)