Files
security-book/00.基础阶段/01.网络基础/02.模拟器安装.md
2025-08-27 14:07:52 +08:00

328 lines
10 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 02.模拟器安装
## 1. PNET模拟器介绍
### 1.1 🔧 为什么要使用 pnet 模拟器?
1. **硬件成本高**
- 真正的 Cisco、华为等路由器/交换机设备价格昂贵,不适合学生或初学者搭建实验环境。
- 模拟器可以“虚拟”真实设备,大幅降低学习门槛和成本。
2. **实验环境灵活**
- pnet 支持快速部署、修改网络拓扑结构,只需拖拽点击即可完成复杂的网络环境搭建。
- 不受物理连接限制,可随意连接任意数量的设备。
3. **近似真实操作**
- pnet 支持运行 **真实厂商的镜像系统**(如 Cisco IOS、华为 VRP、Juniper JunOS 等),操作与真实设备几乎一致。
4. **错误成本低**
- 实验中出错不会损坏真实设备,便于反复试验、练习命令,尤其适合初学者。
5. **可视化与快照功能**
- 支持拓扑图形化界面,操作直观。
- 支持快照/保存,便于回滚、记录学习进度和状态。
6. **高扩展性**
- pnet 可以集成 Linux、Windows、Docker、Firewall如 Palo Alto、Fortigate等系统满足企业级网络学习需求。
- 支持多用户共享平台,适合教学、实验室场景。
## 2. 下载地址
百度网盘地址: https://pan.baidu.com/s/1NH2ycfp6jMg1e9VCXppOKg?pwd=6666
### 2.1 安装vmware
如果之前电脑上已经安装过vmware workstation请勿重复安装如果需要升级版本先正常卸载然后再安装
- 双击安装包
![image-20250620103030182](02.模拟器安装/image-20250620103030182.png)
- 接收许可,点击下一步
![image-20250620103102521](02.模拟器安装/image-20250620103102521.png)
- 如果需要修改安装目录,请选择一个空文件夹!
![image-20250620103218136](02.模拟器安装/image-20250620103218136.png)
- 这两个√可以不需要
![image-20250620103415264](02.模拟器安装/image-20250620103415264.png)
- 保持默认
![image-20250620103511243](02.模拟器安装/image-20250620103511243.png)
- 开始安装
![image-20250620103552810](02.模拟器安装/image-20250620103552810.png)
- 点击许可证
![image-20250620103806678](02.模拟器安装/image-20250620103806678.png)
- 输入序列号`4C21U-2KK9Q-M8130-4V2QH-CF810`
![image-20250620103917432](02.模拟器安装/image-20250620103917432.png)
- 完成安装
![image-20250620104039641](02.模拟器安装/image-20250620104039641.png)
### 2.2 导入pnet虚拟机
- 先解压!先解压!
![image-20250620104127717](02.模拟器安装/image-20250620104127717.png)
- 解压到一个空文件夹中,或者直接点击提取,然后再复制到对应的文件夹中
![image-20250620104221636](02.模拟器安装/image-20250620104221636.png)
- 推荐在D盘中创建vm的文件夹然后将解压后的pnet文件夹放进去
![image-20250620105953595](02.模拟器安装/image-20250620105953595.png)
- 确保电脑中显示文件后缀名
![image-20250620110034332](02.模拟器安装/image-20250620110034332.png)
- 双击pnet.vmx
![image-20250620110059195](02.模拟器安装/image-20250620110059195.png)
- 选择vmware workstation然后点击确定
![image-20250620110140278](02.模拟器安装/image-20250620110140278.png)
- 导入完成
![image-20250620110211746](02.模拟器安装/image-20250620110211746.png)
## 3. PNET环境使用
### 3.1 初始化权限
- 启动pnet虚拟机点击开启此虚拟机
![image-20250620110247614](02.模拟器安装/image-20250620110247614.png)
- 启动成功界面
![image-20250620110822264](02.模拟器安装/image-20250620110822264.png)
- 浏览器访问自己虚拟机的IP地址默认用户名admin密码pnet
![image-20250620110955464](02.模拟器安装/image-20250620110955464.png)
- 登录成功后选择System中的System Setting
![image-20250620111057423](02.模拟器安装/image-20250620111057423.png)
- 点下图所示两个地方
![image-20250620111151095](02.模拟器安装/image-20250620111151095.png)
### 3.2 创建第一个实验
- 新建一个实验
![image-20250620111230888](02.模拟器安装/image-20250620111230888.png)
- 设置好实验名称
![image-20250620111303727](02.模拟器安装/image-20250620111303727.png)
- 右键选择node
![image-20250620111359433](02.模拟器安装/image-20250620111359433.png)
- 此处我们添加一台网络设备所以选择Cisco Device
![image-20250620111440775](02.模拟器安装/image-20250620111440775.png)
- 添加2台网络设备点击Save
![image-20250620111638363](02.模拟器安装/image-20250620111638363.png)
- 连线,当鼠标停在设备上的时候,会出现一个插头,点击拖拽到另一台设备上,就可以完成连线
![image-20250620111803358](02.模拟器安装/image-20250620111803358.png)
![image-20250620111814352](02.模拟器安装/image-20250620111814352.png)
![image-20250620111839578](02.模拟器安装/image-20250620111839578.png)
![image-20250620111849311](02.模拟器安装/image-20250620111849311.png)
- 启动设备鼠标框选需要启动的设备然后右键点击Start Selected
![image-20250620111906364](02.模拟器安装/image-20250620111906364.png)
![image-20250620111938183](02.模拟器安装/image-20250620111938183.png)
![image-20250620111952918](02.模拟器安装/image-20250620111952918.png)
- 打开设备配置界面,点击设备就可以打开,此处将两个设备都打开了,打开后可能是黑的,需要敲几个回车
![image-20250620112106993](02.模拟器安装/image-20250620112106993.png)
- 我们不需要初始化向导所以此处我们统一输入no然后回车
![image-20250620112223328](02.模拟器安装/image-20250620112223328.png)
- 输入命令尝试一下,此处命令是简写,所以看不懂,后面会教大家的,这里只是做个测试
```
=====分割线下面是R1设备上输入的命令=====
en
conf t
ho R1
int e0/0
ip add 192.168.12.1 255.255.255.0
no sh
end
wr
=====分割线下面是R2设备上输入的命令=====
en
conf t
ho R2
int e0/0
ip add 192.168.12.2 255.255.255.0
no sh
end
wr
```
![image-20250620112438861](02.模拟器安装/image-20250620112438861.png)
- 两台设备都输入完成之后,可以测试一下是不是可以`ping`
- 在R1上输入`ping 192.168.12.2`,如果出现如下的界面,说明一切正常
![image-20250620112615780](02.模拟器安装/image-20250620112615780.png)
## 4. 设备初始化配置
1. 首先跳过设置向导
```
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no
Press RETURN to get started!
```
2. 从用户模式切换到特权模式(不然获得设备的完整权限)
```
Router>enable # 这边可以看到设备初始的名字是Router
Router# # 这边可以看到>变为#,意思是进入特权模式
```
3. 如果想修改设备名之类的全局属性,需要进入全局配置模式
```
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)# # 注意,()中表示的是当前的配置影响范围如果是config表示影响全局
```
4. 修改设备名
```
Router(config)#hostname R1 # 工作中设备名都是有意义的
R1(config)#
```
5. 关闭域名解析(推荐)
```
R1(config)#no ip domain lookup # 不关闭会导致命令错误的时候设备去尝试查找命令对应的IP
```
6. 配置IP地址
```
R1(config)#interface e0/0 # 进入e0/0接口的配置模式
R1(config-if)#ip address 192.168.12.1 255.255.255.0 # 注意括号变成了config-if表示影响范围是接口
R1(config-if)#no shutdown # 为了安全默认所有接口出厂都自带shutdown属性要删除这个命令就在前面加上no
```
7. 优化管理接口的配置
```
R1(config)#line console 0 # 进入控制台配置模式
R1(config-line)#exec-timeout 0 # 关闭控制台会话超时
R1(config-line)#logging synchronous # 输出同步,防止敲命令被打断
```
8. 给设备加上密码
```
R1(config)#enable password 密码 # 给特权模式加上密码
R1(config)#line console 0
R1(config-line)#password cisco # 设置控制台的密码
R1(config-line)#login # 启用密码校验
User Access Verification
Password: # 这边要输入控制台密码
R1>enable
Password: # 这边要输入特权模式密码
R1#
```
## 5. 命令行小技巧
### 5.1 命令提示
```
R1>en? # 紧贴着字母后面输入?,可以查看这个字母开头的可用命令
enable
R1>enable
R1#con? # 这边查询到当前有两个con开头的可用命令
configure connect
R1#configure ? # 如果在空格后面加上?,表示查询当前命令后面能加上什么参数,以及解释
confirm Confirm replacement of running-config with a new config
file
memory Configure from NV memory
network Configure from a TFTP network host
overwrite-network Overwrite NV memory from TFTP network host
replace Replace the running-config with a new config file
revert Parameters for reverting the configuration
terminal Configure from the terminal
<cr> # 如果出现<cr>,表示当前输入的命令已经可以直接执行了
```
### 5.2 自动补全
```
R1(config)#int # 在int后面加上tab键就可以自动补全后续字母
R1(config)#interface
R1#con # 由于con开头有两个可用命令所以存在歧义不可以补全
R1#con?
configure connect
```
### 5.3 命令简写
```
R1#conf t # 这个命令是configure terminal简写
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ho R1 # 这个命令是hostname R1简写
R1(config)#int e0/0 # 这个命令是interface e0/0简写
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no sh # 这个命令是no shutdown简写
```
### 5.4 错误提示
```
R1(config)#int
% Incomplete command. # 命令不完整,缺少参数
R1(config)#s
% Ambiguous command: "s" # 未知的命令,输入错误了
R1(config)#interfcaes e0/0
^
% Invalid input detected at '^' marker. # 箭头所指的位置出现错误
```