资源

就是看这个入门的,对新手友好,快速上手https://www.bilibili.com/video/BV1iv411B7MG?p=50

一些可能用到的资源,比如用防火墙需要导入一个包,但是按照提示,在华为的官网没有找到,但在这里有http://network.book.51xueweb.cn/resource.html

ensp的一些基础命令

一、
system-view 进入系统视图
undo info-center enable 关闭消息中心
sysname 更改设备名称
stp disable/enable关闭开启生成树协议
display current-configuration 显示配置信息
display vlan 显示vlan信息
display interface显示交换机接口信息
dispaly macaddress查看mac交换地址表
dispaly interface Ethernet brief查看交换机接口模式,接口速率
静态地址接口绑定 mac-address static 主机物理地址 接口
二、
interface进入指定接口
如:interface GigabitEthernet 0/0/1
description 更改接口描述
undo negotiation auto 改为非自协商模式
duplex full改为全双工模式
speed 100 配置速率为100
mac-address learning disable action discard关闭自学习功能
三、
链路聚合
interface Eth-Trunk 1创建链路组,进入指定接口后加入链路组Eth-Trunk 1
四、配置vlan
1、基于端口的vlan配置
创建vlan: vlan 名字
批量创建: vlan batch 多个名字
进入接口,将接口划入vlan
port link-type access设置连接类型为access
port default vlan vlan名
2、跨交换机应用vlan
将GE接口
port link-type Trunk
port trunk allow-pass vlan 允许通过的vlan名
3、基于mac地址的vlan 配置
创建vlan后进入vlan
mac-vlan mac-address mac地址 进行绑定
将GE接口
mac-vlan enable
port link-type hybrid
port trunk allow-pass vlan 允许通过的vlan名
4、不同vlan间的svi配置
interface vlanif vlan名 创建虚拟接口
ip address ip地址 掩码
显示路由信息 display ip routing-table
五、路由器
配置默认路由 ip route-static 0.0.0.0 0.0.0.0 ip地址
配置路由器接口地址 ip address ip地址
六、配置ospf
ospf 名字
area 名字
network ip 掩码 宣告区域直连的网络
七、
quit退出命令
用户视图下
save保存配置
reboot重启
reset saved-configuration重置设备
八、防火墙配置
配置不信任的接口
firewall zone untrust
add interface 接口名
security-policy进入安全策略
rule name 名字新建策略
source-address ip mask 掩码
destination-address ip mask 掩码
service any(服务名)
action permit或deny

配置时遇到的几个坑

一、如果想要使用NAT等服务,不要使用router这个路由

怎么用ensp测试python脚本 ensp实验教程_怎么用ensp测试python脚本

二、ACL number是有区别的

acl 100 是用在WLAN 里的。acl 2000 只可以匹配 三层的源地址 称为基本acl。acl 3000 可以匹配 三层报文的源地址和目的地址以及四层的端口号 称为高级acl。acl 4000 用来匹配2层的相关报文 源MAC 目的MAC。acl 5000 用户自定义的以报文的报文头、IP头等为基准,指定从第几个字节开始与掩码进 行 与 操作。(来自https://bbs.51cto.com/thread-941657-1-1.html?_t=1510150481

ACL参考https://blog.51cto.com/yuan2/1583305

三、关于NAT的配置
https://blog.csdn.net/qq_46258964/article/details/108143461https://www.cnblogs.com/qi-yuan/p/12024450.html

实例

场景一

老校区内部网络分为办公区域和服务器区域。办公区域内部IP地址段为192.168.1.0/24;ISP提供的公网地址为202.102.192.9。服务器区域有一台内部文件服务器(内部IP:192.168.0.10),ISP提供的公网IP地址为202.102.192.10;新校区IP地址段为200.110.10.0/24;未授权用户IP地址段为100.110.10.0/24。办公区域用户要求能访问互联网。内部文件服务器仅对外提供21端口的访问。文件服务器仅允许新校区授权IP地址能够访问,非授权IP地址不能访问。

拓扑规划

怎么用ensp测试python脚本 ensp实验教程_Ethernet_02

设备名称

IP地址

说明

PC-1

192.168.1.0/24

表示办公区域内网主机,采用DHCP随机分配地址,访问外网时采用IP:202.102.192.9

Client-1

192.168.1.2

表示办公区域内网主机,访问外网时采用IP:202.102.192.9

Server-FTP

内网:192.168.0.2 外网:202.102.192.10

服务区域内网提供文件服务主机,对外只允许新区授权用户访问,只开放21端口

Client-2

220.110.10.2

表示新区授权用户主机

Client-3

100.110.10.2

表示新区未授权用户主机

SW-1


二层交换机,用于连接办公区域设备,并与三层交换机LSW-1相连

SW-2


二层交换机。用于连接服务区域设备,并与三层交换机LSW-1相连

LSW-1

GE 0/0/1:192.168.2.254 GE 0/0/2:192.168.1.254 GE 0/0/3:192.168.0.254

三层交换机,用于连接老区办公区域和服务区域两个网络,并和外部路由器相连

R1

GE 0/0/1:192.168.2.1 GE 0/0/0:202.102.192.9

老区内网与外部相连边界路由器,需要提供NAT服务和ACL控制

R2

GE 0/0/1:200.110.10.254 GE 0/0/2:100.110.10.254 GE 0/0/3:200.110.20.254

新区路由器,连接授权用户和非授权用户

FW1

GE 1/0/0:202.102.192.1 GE 1/0/1:200.110.20.1

防火墙

vlan划分

Vlan

网段

接口

包含主机

Vlan10

192.168.1.0/24

SW1 Ethernet 0/0/1

老区办公网络PC1,client1等

Vlan20

192.168.0.0/24

SW2 Ethernet 0/0/1

老区服务网络server-FTP

Vlan30

192.168.0.2/24

FWS1 GigabitEthernet 0/0/1

三层交换机LSW1与路由器R1

Vlan虚接口设置

虚接口

IP

子网掩码

Vlanif 10

192.168.1.254

255.255.255.0

Vlanif 20

192.168.0.254

255.255.255.0

Vlanif 30

192.168.2.254

255.255.255.0

配置命令

一、SW1
system-view
sysname SW1
undo info-center enable //关闭消息通知,不然很烦
vlan 10//划分vlan
quit
//将接口加入到vlan中
interface Ethernet 0/0/1
port link-type access
port default vlan 10
interface Ethernet 0/0/2
port link-type access
port default vlan 10

interface GigabitEthernet 0/0/1
port link-type Trunk
port trunk allow-pass vlan 10

quit
quit
save

二、SW2
system-view
sysname SW2
undo info-center enable
vlan 20
quit
interface Ethernet 0/0/1
port link-type access
port default vlan 20
interface GigabitEthernet 0/0/1
port link-type Trunk
port trunk allow-pass vlan 20
quit
quit
save

三、LSW1
system-view
sysname LSW1
undo info-center enable
vlan batch 10 20 30
interface GigabitEthernet 0/0/2
port link-type Trunk
port trunk allow-pass vlan 10 20 30
interface GigabitEthernet 0/0/3
port link-type Trunk
port trunk allow-pass vlan 10 20 30
interface GigabitEthernet 0/0/1
port link-type access
port default vlan 30
quit

//vlan虚接口(虚网关?)
interface vlanif 10
ip address 192.168.1.254 255.255.255.0
interface vlanif 20
ip address 192.168.0.254 255.255.255.0
interface vlanif 30
ip address 192.168.2.254 255.255.255.0
quit

//dhcp服务,自动分配ip
dhcp enable
ip pool vlan10
gateway-list 192.168.1.254 //网关
network 192.168.1.0 mask 255.255.255.0
//excluded-ip-address 192.168.1.1
interface vlanif 10 //绑定端口
dhcp select global
//主机需要配为dhcp

//路由协议,这里仅划为area一个区域
ospf 1
area 0
//宣告所连接的网络
network 192.168.0.0 0.0.0.255
network 192.168.1.0 0.0.0.255
network 192.168.2.0 0.0.0.255
quit
quit
save

四、RS1
system-view
sysname RS1
undo info-center enable
//为接口分配ip
interface GigabitEthernet 0/0/1
ip address 192.168.2.1 255.255.255.0
interface GigabitEthernet 0/0/0
ip address 202.102.192.9 255.255.255.0
quit

ospf 1
area 0
network 192.168.2.0 0.0.0.255
network 202.102.192.0 0.0.0.255
quit
quit
save

//配置ACL
acl number 2000
rule 5 permit source 200.110.10.0 0.0.0.255
rule 10 permit source 192.168.1.0 0.0.0.255
rule 15 permit source 192.168.0.0 0.0.0.255
rule 20 deny source 100.110.10.0 0.0.0.255
quit
//将ACL绑定到指定端口
interface GigabitEthernet 0/0/0
traffic-filter inbound acl 2000

//NAT服务
interface GigabitEthernet 0/0/0
nat outbound 2000
//nat static global 202.102.192.9 inside 192.168.0.2这是静态的配置
nat server protocol tcp global 202.102.192.10 ftp inside 192.168.0.2 ftp
nat alg ftp enable
quit
save

五、RS2
system-view
sysname RS2
interface GigabitEthernet 0/0/0
ip address 200.110.20.254 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 200.110.10.254 255.255.255.0
interface GigabitEthernet 0/0/2
ip address 100.110.10.254 255.255.255.0

ospf 1
area 0
network 200.110.10.0 0.0.0.255
network 100.110.10.0 0.0.0.255
network 200.110.20.0 0.0.0.255

六、FW1
system-view
sysname FW1
interface GigabitEthernet 1/0/0
ip address 202.102.192.1 255.255.255.0
interface GigabitEthernet 1/0/1
ip address 200.110.20.1 255.255.255.0
firewall zone untrust
add interface GigabitEthernet 1/0/1
add interface GigabitEthernet 1/0/0

ospf 1
area 0
network 200.110.20.0 0.0.0.255
network 202.102.192.0 0.0.0.255
quit

验证

一、FTP服务开启

怎么用ensp测试python脚本 ensp实验教程_内网_03

二、查看R1路由表,通过ospf建立了路由

怎么用ensp测试python脚本 ensp实验教程_怎么用ensp测试python脚本_04

PC-1 ping外网,正常通信,并且采用外网地址访问通信

怎么用ensp测试python脚本 ensp实验教程_怎么用ensp测试python脚本_05

用新区授权用户Client2访问FTP服务器,并且抓包。成功登录,抓包中可以看到建立了tcp连接,并且传送了用户名密码等信息。

怎么用ensp测试python脚本 ensp实验教程_内网_06

怎么用ensp测试python脚本 ensp实验教程_内网_07

使用未授权用户client3访问ftp服务器,无法连接,验证只允许授权用户连接

怎么用ensp测试python脚本 ensp实验教程_Ethernet_08

场景二

有3个校区,通过租用运营商的专线实现互联;3个校区之间要求互联互通;南区财务服务器IP地址为:10.0.3.2。要求三个校区网络互通 。财务服务器仅提供3个校区的财务vlan能够访问,其他vlan不能访问。

拓扑规划

怎么用ensp测试python脚本 ensp实验教程_内网_09

设备名称

IP地址

说明

Server

10.0.3.2

屯溪路校区财务服务器

PC1

10.0.3.0/24

表示屯溪路内网主机,采用DHCP随机分配地址

Client1

10.0.3.3

表示屯溪路内网主机

PC2

10.0.2.0/24

表示翡翠湖内网主机,采用DHCP随机分配地址

Client2

10.0.2.3

表示翡翠湖内网主机

PC3

10.0.1.0/24

表示宣城内网主机,采用DHCP随机分配地址

Client3

10.0.1.3

表示屯溪路内网主机

PC4

10.0.0.0/24

其它,用于验证

Client4

10.0.0.0

其它,用于验证

SW1


屯溪路交换机

SW2


翡翠湖交换机

SW3


宣城交换机

SW4


其它,用于验证

LSW1

GE 0/0/1:10.0.3.254 GE 0/0/2:10.0.2.254 GE 0/0/3:10.0.1.254 GE 0/0/4:10.0.0.254

三层交换机,用于各校区互连

vlan设置

Vlan

网段

接口

包含主机

Vlan10

10.0.3.254

SW1:Ethernet 0/0/1,Ethernet 0/0/2,Ethernet 0/0/3

屯溪路校区主机,财务服务器

Vlan20

10.0.2.254

SW2:Ethernet 0/0/1,Ethernet 0/0/2

翡翠湖校区主机

Vlan30

10.0.1.254

SW3:Ethernet 0/0/1,Ethernet 0/0/2

宣城校区主机

Vlan40

10.0.0.254

SW4:Ethernet 0/0/1,Ethernet 0/0/2

用于验证

配置命令

1、SW1
system-view
sysname SW1
undo info-center enable
vlan 10
quit
interface Ethernet 0/0/1
port link-type access
port default vlan 10
interface Ethernet 0/0/2
port link-type access
port default vlan 10
interface Ethernet 0/0/3
port link-type access
port default vlan 10
interface GigabitEthernet 0/0/1
port link-type Trunk
port trunk allow-pass vlan 10 20 30
quit
quit
save

acl number 3000
rule 0 permit ip source 10.0.3.0 0.0.0.255 destination 10.0.3.2 0.0.0.0
rule 5 permit ip source 10.0.2.0 0.0.0.255 destination 10.0.3.2 0.0.0.0
rule 10 permit ip source 10.0.1.0 0.0.0.255 destination 10.0.3.2 0.0.0.0
rule 15 deny ip source any destination 10.0.3.2 0.0.0.0
interface GigabitEthernet 0/0/1
traffic-filter inbound acl 3000

2、SW2
system-view
sysname SW2
undo info-center enable
vlan 20
quit
interface Ethernet 0/0/1
port link-type access
port default vlan 20
interface Ethernet 0/0/2
port link-type access
port default vlan 20
interface GigabitEthernet 0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
quit
quit
save

3、SW3
system-view
sysname SW3
undo info-center enable
vlan 30
quit
interface Ethernet 0/0/1
port link-type access
port default vlan 30
interface Ethernet 0/0/2
port link-type access
port default vlan 30
interface GigabitEthernet 0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
quit
quit
save

4、SW4
system-view
sysname SW4
undo info-center enable
vlan 40
quit
interface Ethernet 0/0/1
port link-type access
port default vlan 40
interface Ethernet 0/0/2
port link-type access
port default vlan 40
interface GigabitEthernet 0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30 40
quit
quit
save

5、LSW1
system-view
sysname LSW1
undo info-center enable
vlan batch 10 20 30 40
interface GigabitEthernet 0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
interface GigabitEthernet 0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30
interface GigabitEthernet 0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20 30
interface GigabitEthernet 0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20 30 40

interface vlanif 10
ip address 10.0.3.254 255.255.255.0
interface vlanif 20
ip address 10.0.2.254 255.255.255.0
interface vlanif 30
ip address 10.0.1.254 255.255.255.0
interface vlanif 40
ip address 10.0.0.254 255.255.255.0
quit

dhcp enable
ip pool vlan10
gateway-list 10.0.3.254
network 10.0.3.0 mask 255.255.255.0
quit
interface vlanif 10
dhcp select global
ip pool vlan20
gateway-list 10.0.2.254
network 10.0.2.0 mask 255.255.255.0
quit
interface vlanif 20
dhcp select global
ip pool vlan30
gateway-list 10.0.3.254
network 10.0.1.0 mask 255.255.255.0
quit
interface vlanif 30
dhcp select global
ip pool vlan40
gateway-list 10.0.0.254
network 10.0.0.0 mask 255.255.255.0
quit
interface vlanif 40
dhcp select global

ospf 1
area 0
network 10.0.3.0 0.0.0.255
network 10.0.2.0 0.0.0.255
network 10.0.1.0 0.0.0.255
network 10.0.0.0 0.0.0.255
quit
quit
save