本次实验模拟学校实验室的网络环境,通过虚拟环境进行组网,通过vlan、路由、访问控制等,实现不同实验室之间的通信,并且可以通过ACL控制某一个实验室的网络通信,进行简单的组网分析
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]vlan batch 201 202 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]q
//使用此命令可以关闭日志
<Huawei>undo terminal monitor
Info: Current terminal monitor is off.
<Huawei>sys
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 201
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 202
[Huawei]int vlanif 201
[Huawei-Vlanif201]ip address 10.1.1.1 24
[Huawei-Vlanif201]int vlanif 202
[Huawei-Vlanif202]ip add 10.1.2.1 24
//此处配置vlan20是为了保证与上层的通信
[Huawei]vlan 20
[Huawei]int vlanif 20
[Huawei-Vlanif20]ip add 192.168.2.2 24
为了保证LSW1与核心交换机之间的数据传输,在他们之间进行链路聚合,即将三条链路聚合为一两条逻辑链路Eth-Trunk1,从而保证他们之间数据的转发(此处采用的链路聚合模式为LACP模式)
[Huawei]int Eth-Trunk 1
//将模式改为lacp
[Huawei-Eth-Trunk1]mode lacp-static
[Huawei-Eth-Trunk1]trunkport g0/0/4
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]trunkport g0/0/5
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]trunkport g0/0/3
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]q
//改变优先级,优先级小越优先,默认值为32768,此处改为100,则LSW1端为主动方
[Huawei]lacp priority 100
[Huawei]int Eth-Trunk 1
//此命令表示LACP模式下有两条活跃链路,一条备份链路
[Huawei-Eth-Trunk1]max active-linknumber 2
[Huawei]dis interface Eth-Trunk 1
Eth-Trunk1 current state : UP
Line protocol current state : UP
Description:
Switch Port, PVID : 1, Hash arithmetic : According to SIP-XOR-DIP,Maximal BW:
3G, Current BW: 2G, The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc45-6681
Current system time: 2020-04-20 21:14:48-08:00
Input bandwidth utilization : 0%
Output bandwidth utilization : 0%
-----------------------------------------------------
PortName Status Weight
-----------------------------------------------------
GigabitEthernet0/0/3 UP 1
GigabitEthernet0/0/4 DOWN 1
GigabitEthernet0/0/5 UP 1
-----------------------------------------------------
The Number of Ports in Trunk : 3
The Number of UP Ports in Trunk : 2
在vlanif接口中配置DHCP
配置命令
[Huawei]dhcp enable
[Huawei]int vlanif 201
[Huawei-Vlanif201]dhcp select interface
[Huawei-Vlanif201]int vlanif 202
[Huawei-Vlanif202]dhcp select interface
此处201教室可以分配的地址为10.1.1.0网段,202教室可以分配的地址是10.1.2.0网段
dhcp详细内容可以参考:DHCP协议分析
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]port link-type trunk
[Huawei-Eth-Trunk1]port trunk allow-pass vlan 201 202 20
将所有二楼的实验室划入vlan20
并且在此处配置链路聚合
配置命令
//此处创建三个vlan是为了保证与上层路由器和三楼所有主机的通信
[Huawei]vlan batch 20 30 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int vlanif 20
[Huawei-Vlanif20]ip add 192.168.2.1 24
[Huawei]int vlanif 30
[Huawei-Vlanif30]ip add 192.168.3.1 24
//此处配置vlanif100是为了保证与上层的通信
[Huawei]int vlanif 100
[Huawei-Vlanif100]ip add 192.168.6.2 24
LSW3是LSW1的对端,我们将LSW1配置为了主动方,则LSW3为被动方
与二楼交换机通信的配置命令
[Huawei]int Eth-Trunk 2
[Huawei-Eth-Trunk2]mode lacp-static
[Huawei-Eth-Trunk2]trunkport g0/0/1
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk2]trunkport g0/0/7
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk2]trunkport g0/0/8
Info: This operation may take a few seconds. Please wait for a moment...done.
//此处的链路聚合为手工负载分担
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]trunkport g0/0/5
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]trunkport g0/0/6
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]trunkport g0/0/2
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei-Eth-Trunk1]dis eth-trunk 1
Eth-Trunk1's state information is:
WorkingMode: NORMAL Hash arithmetic: According to SIP-XOR-DIP
Least Active-linknumber: 1 Max Bandwidth-affected-linknumber: 8
Operate status: up Number Of Up Port In Trunk: 3
--------------------------------------------------------------------------------
PortName Status Weight
GigabitEthernet0/0/5 Up 1
GigabitEthernet0/0/6 Up 1
GigabitEthernet0/0/2 Up 1
//与二楼通信
[Huawei]int vlanif 20
[Huawei-Vlanif20]ip add 192.168.2.1 24
[Huawei]int Eth-Trunk 2
[Huawei-Eth-Trunk2]port link-type trunk
[Huawei-Eth-Trunk2]port trunk allow-pass vlan 201 202 20
[Huawei-Eth-Trunk2]q
//与三楼通信
[Huawei]int vlanif 30
[Huawei-Vlanif30]ip add 192.168.3.1 24
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]port link-type trunk
[Huawei-Eth-Trunk1]port trunk allow-pass vlan 301 302 30
[Huawei-Eth-Trunk1]q
将所有的下层的vlan都统一汇聚为vlan100,从而与上层路由器进行通信
//通过此逻辑地址与上层路由器进行通信
[Huawei]int vlanif 100
[Huawei-Vlanif100]ip add 192.168.6.2 24
[Huawei-Vlanif100]q
//与左侧路由器通信
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port trunk allow-pass vlan 100
[Huawei-GigabitEthernet0/0/3]q
//与右侧路由器通信
[Huawei]int g0/0/4
[Huawei-GigabitEthernet0/0/4]port trunk allow-pass vlan 100
因为从LSW3发送的数据包它含有vlan标签,但是路由器不能处理带标签的数据帧,所以此处想到了通过单臂路由的方式去解决这以问题,及通过配置逻辑子接口,从而可以剥离vlan标签
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]ip add 192.168.6.1 24
[Huawei-GigabitEthernet0/0/0.1]dotlq termination vid 100
//此处为可转换的的地址池
[Huawei]nat address-group 1 192.168.0.150 192.168.0.250
[Huawei]acl 2000
[Huawei-acl-basic-2000]rule 5 permit source 10.0.0.0 0.255.255.255
[Huawei-acl-basic-2000]q
[Huawei]int g2/0/0
[Huawei-GigabitEthernet2/0/0]nat outbound 2000 address-group 1 no-pat
//创建访问控制列表2000
[Huawei]acl 2000
[Huawei-acl-basic-2000]
//控制规则为拒绝源地址10.2.2.0网段,及302教室
[Huawei-acl-basic-2000]rule deny source 10.2.2.0 0.0.0.255
[Huawei-acl-basic-2000]q
//在链路聚合后的逻辑接口Eth-Trunk1中配置:在出方向上执行此规则
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]traffic-filter outbound acl 2000
在核心交换机与上层路由器进行通信时,为了防止左侧链路出现故障,从而配置右侧备份链路
//此处配置的含义可以参考AR2的配置
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]ip add 192.168.6.3 24
[Huawei-GigabitEthernet0/0/0.1]dotlq termination vid 100
//改变路由优先级,当左侧链路出现故障时,则会选择右侧链路
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.6.3 preference 70
[Huawei]int g0/0/6
[Huawei-GigabitEthernet0/0/6]port link-type trunk
//此处的配置是为了保证与右侧可以通过GigabitEthernet0/0/6端口进行通信
[Huawei-GigabitEthernet0/0/6]port trunk allow-pass vlan 201 202 301 302 100
[Huawei-GigabitEthernet0/0/6]q
[Huawei]ospf 1
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]network 10.1.0.0 0.0.255.255
[Huawei-ospf-1-area-0.0.0.1]network 192.168.2.0 0.0.0.255
[Huawei]ospf 1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
以上是区域0的配置,其他三个路由器的配置都可参考此处
具体OSPF的介绍可点击此处
网盘链接点击此处,提取码:as96
其他内容可关注个人博客!不将就