[toc]

下载镜像

选择镜像

1.XFCE

Xfce 是一个用于类 UNIX 操作系统的轻量级桌面环境。它的目标是快速和低系统资源,同时仍然具有视觉吸引力和用户友好性。Xfce 体现了传统的 UNIX 模块化和可重用性哲学。它由许多组件组成,这些组件提供了现代桌面环境所期望的全部功能。它们是单独包装的,您可以在可用的软件包中进行选择,以创建最佳的个人工作环境。

XFCE

2.KDE Plasma

KDE Plasma 适合那些想要用户友好和可定制桌面的人。它是一个功能丰富且用途广泛的桌面环境,提供多种不同风格的菜单来访问应用程序。一个出色的内置界面,可以轻松访问和安装来自互联网的新主题、小部件等,也值得一提。默认情况下,KDE Plasma 很简单,它是一个干净的工作区域,供实际使用,不会妨碍您,因此用户可以创建工作流程,从而更有效地完成任务。

KDEPlasma

3.GNOME

对于想要一个非常现代和简单的桌面的人

简单来说,这就是像ubuntu那样的桌面,算是极简主义者的天堂了。

GNOME

制造启动U盘

下载工具

这里我们去balenaEtcher的官网下载一个便携式的u盘刻录工具,萌新前期可以通过这个工具把我们需要装的系统刻录进u盘中。(如果觉得一次只能刻录一个镜像而感到苦恼的话,也可以去ventoy官网下载ventoy这款无敌的工具,能够兼容多个系统镜像,真正让你的u盘不再唯一)

刻录好u盘之后我们可以开始进行我们的系统安装了!!!

1.单系统(manjaro)

2.双系统(window10 + manjaro)

一.与window10 efi 共存方案

二.单独一个 manjaro efi 方案

三.如何删除双系统下的manjaro系统

注意事项

直接在window系统上面格式化manjaro的磁盘是不能完全删除manjaro的,这样做会触发efi检测不到manjaro硬盘而进入grub模式!!!

1.EFI根除教程

1.删除EFI首先在cmd里面把装系统的那个分区显现出来,并且赋予盘符号。

  • 1.用diskpart来对磁盘进行操作

  • 然后给diskpart授权开启

  • 2.查看磁盘命令

  • 3.选中目标磁盘0用select disk 0命令

  • 4.列出该磁盘下的所有分区信息用list partition命令

  • 5.选择我们的EFI系统分区用select partition 1命令(在这一步也可以删掉选中盘的所有内容(命令是delete partition override)(执行这条命令相当于把那个分区抹去了))

  • 6.用命令给这个EFI分区赋予盘符之后,它就会像一个磁盘出现在电脑里面,命令是assign letter=p(这里p是盘符号,你也可以按照自己喜欢来打其他字母,只要不重复就好。)

  • 7.然后你就神奇的发现多了一个p盘分区(这个叫SYSTEM的磁盘分区就是那个EFI)

  • 8.这个时候你可以使用新建文本文档在里面打开这个p盘里面删掉EFI里面的系统启动文件或者用Total Commander 64 bit这个东西来删除里面的删掉EFI里面的系统启动文件千万别把整个EFI干掉,那就是一把梭,莽!!!


  • 然后移除盘符p用命令remove letter=p

2.删除卷

右键此电脑—>单击管理—>单击磁盘管理—>找到你分配给manjaro的磁盘,直接右击删除卷,然后重新添加新的分区就行了。

3.manjaro系统入门操作(过不了就躺板板吧,别学了)

换源

1.换国内软件源

安装完成manjaro的第一步就是给manjaro换上国内源,使接下来能安装软件等其他操作。

1
sudo pacman-mirrors -i -c China -m rank #在弹出来的面板选择一道两个时间短的源

下面这个跟上面那一步操作类似,它是直接把源放入到文件里面一步到位(注意:这个源要放文件内容最前面),有上面命令的操作可以跳过导入源到mirrorlist这一步。

首先把这几个源加入到这个文件里面:

1
sudo vi /etc/pacman.d/mirrorlist    #因为没有软件源,我没办法下载vim,所以这里我用的编辑器是vi,你们可以使用nano
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## Country : China
Server = https://mirrors.huaweicloud.com/manjaro/stable/$repo/$arch

## Country : China
Server = https://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch

## Country : China
Server = https://mirrors.sjtug.sjtu.edu.cn/manjaro/stable/$repo/$arch

## Country : China
Server = https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch

## Country : China
Server = https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch

2.添加cn软件源(完成这步,就可以正常下载东西了)

这里我使用的是中科大的软件源:

1
sudo vi /etc/pacman.conf
1
2
3
4
#中科大源
[archlinuxcn]
SigLevel = Optional TrustedOnly
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
1
2
pacman -Syyu                     #更新整个系统
pacman -S archlinuxcn-keyring #安装密钥环密钥
注意:如果更新的时候出现manjaro pacman:“GPGME错误:无数据”问题

如下所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pacman -Syyu
错误:GPGME error: 无数据
错误:GPGME error: 无数据
错误:GPGME error: 无数据
错误:GPGME error: 无数据
错误:GPGME error: 无数据
:: 正在同步软件包数据库...
core 已经是最新版本 0.0 B 0.00B/s 00:00 [----------------------] 0%
extra 已经是最新版本 0.0 B 0.00B/s 00:00 [----------------------] 0%
community 已经是最新版本 0.0 B 0.00B/s 00:00 [----------------------] 0%
multilib-testing 已经是最新版本 B 0.00B/s 00:00 [----------------------] 0%
multilib 已经是最新版本 0.0 B 0.00B/s 00:00 [----------------------] 0%
错误:数据库 'core' 无效 (无效或已损坏的数据库 (PGP 签名))
错误:数据库 'extra' 无效 (无效或已损坏的数据库 (PGP 签名))
错误:数据库 'community' 无效 (无效或已损坏的数据库 (PGP 签名))
错误:数据库 'multilib-testing' 无效 (无效或已损坏的数据库 (PGP 签名))
错误:数据库 'multilib' 无效 (无效或已损坏的数据库 (PGP 签名))

只需要执行这条命令就可以正常启动

1
sudo rm -R /var/lib/pacman/sync

常用工具

1.vim编辑工具

1
sudo pacman -S vim         # vim编辑器永远的神

2.时间同步(非常重要,影响科学上网的vmess协议)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#硬件时间and系统时间
#这2个时间不是同步的!如果有一天发现系统的时间不对了,可以分别看看这2个时间。硬件时间写在BIOS里,系统时间就是电脑显示的时间了。
#这个显示的时硬件时间。
sudo hwclock -r
[sudo] $home 的密码:
2022-01-21 17:28:32.107794+08:00

#在使用ntpdate同步网络时间后可以将时间写入到BIOS:
#同步网络时间:
sudo ntpdate time.windows.com
21 Jan 17:30:46 ntpdate[1898]: adjust time server 20.189.79.72 offset -0.276329 sec

#写入BIOS:
sudo hwclock -w #写入BISO
#再看看现在的时间
sudo hwclock -r
2014年12月31日 星期三 20时26分03秒 -0.979207 seconds

3.安装yay

1
sudo pacman -S yay #yay可以安装archlinux wiki上面的AUR软件包,给archlinux点赞

Archlinux庞大的AUR软件包地址,需要软件包直接进去搜索

4.安装一个非常重要的基础库base-devel

1
2
3
4
5
6
7
sudo pacman -S base-devel
#:: 在组 base-devel 中有 24 成员:
#:: 软件仓库 core
1) autoconf 2) automake 3) binutils 4) bison 5) fakeroot 6) file 7) findutils 8) flex 9) gawk
10) gcc 11) gettext 12) grep 13) groff 14) gzip 15) libtool 16) m4 17) make 18) pacman 19) patch
20) pkgconf 21) sed 22) sudo 23) texinfo 24) which
#这个基础包必须安装,否则我们在使用yay安装AUR软件的时候经常会遇到安装不上的问题。

5.浏览器

谷歌浏览器
1
yay -S google-chrome
Chromium
1
sudo pacman -S chromium
火狐浏览器
1
sudo pacman -S firefox

中文汉化

1
sudo pacman -S firefox-i18n-zh-cn

6.办公套件WPS

虽然安装manjaro的时候让你选择了办公套件,但是全英文的真是一言难尽。还是用回国产吧!

那就直接AUR库安装wps咯

1
yay -S wps-office-mui-zh-cn wps-office-mime-cn wps-office-cn wps-office-fonts ttf-ms-fonts  ttf-wps-fonts

ttf-wps-fontswps-office-fontsttf-ms-fonts是安装字体的,可选安装的,我这就懒了,直接一把梭呗!

7.安装Jetbra全家桶(以Pycharm为例子)

Manjaro_install_Pycharm_Professional

8.安装obs

使用命令下面命令安装

1
yay -S obs-studio

你启动obs的时候可以看到启动然后马上闪退

这里只需要把libva-vdpau-driver这个包删了就行了

1
sudo pacman -R libva-vdpau-driver

然后,就能正常使用obs了

Screenshot_20231122_150148

但是。。。我手贱没将它加入忽略更新里面,敲了一次sudo pacman -Syyu这个obs就挂了

好吧!试一下编译安装

1
yay -S obs-studio-rc

这个倒是没问题了,所以不确定的包,尽量别更新,趁早丢忽略更新里头。

好好查查文档,想玩好arch就得看官方文档,上游更新之后,系统只要滚一下就是最新的了,所以很多问题都没有披露就被你“趁热”吃上了。

obs官网

obs-studio-github

obs-studio-github-install

安装输入法

Fcitx5 官方文档
中文及日文输入法均体验良好。

1
2
3
4
5
6
sudo pacman -S fcitx5-im #基础包组
sudo pacman -S fcitx5-chinese-addons #官方中文输入引擎
sudo pacman -S fcitx5-anthy #日文输入引擎
yay -S fcitx5-pinyin-moegirl #萌娘百科词库 由于中国大陆政府对github封锁,你可能在此卡住。如卡住,可根据后文设置好代理后再安装
sudo pacman -S fcitx5-pinyin-zhwiki #中文维基百科词库
sudo pacman -S fcitx5-material-color #主题

设置环境变量 编辑文件 sudo vim /etc/environment 加入以下内容。konsole 以及 dolphin 都需要这些环境变量,倒是 chrome 和 firefox 都不需要就可以输入中文

1
2
3
4
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx

打开 系统设置 > 区域设置 > _输入法_,先点击运行Fcitx即可,拼音为默认添加项。如你还需要更多输入法如五笔,则再点击添加输入法,找到简体中文下的五笔 ,点击添加即可加入五笔输入法。(建议,无论什么输入法都留一个英文的输入法在首位置)。

接下来点击 拼音 右侧的配置按钮,点选云拼音在程序中显示预编辑文本 最后应用。

回到输入法设置,点击配置附加组件,找到 经典用户界面 在主题里选择一个你喜欢的颜色 最后应用。

注销,重新登陆,就可以发现已经可以在各个软件中输入中文了

聊天工具

我们日常使用的聊天工具无非就是微信,QQ,Telegram

这个时候,我们可以去Archlinux庞大的AUR软件里面搜索

1
2
3
4
5
6
#微信(已经是孤儿包不维护了)
yay -S deepin-wine-wechat
#QQ(已经是孤儿包不维护了)
yay -S deepin-wine-qq
#Telegram
sudo pacman -S telegram-desktop

科学上网(没有经验的直接跳过)

服务器端(Server端)

1.科学上网服务器(外网服务器一台)
1
2
# 系统是centos7,更新软件
yum update -y && yum upgrade && yum install curl -y && yum -y install wget
1
2
# 脚本
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh
2.开启BBR加速

2然后选19懂???

1
2
3
wget --no-check-certificate -O tcpx.sh https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcpx.sh && chmod +x tcpx.sh && ./tcpx.sh
uname -r
lsmod | grep bbr
不喜欢上面的一键脚本可以试一下X-UI
1
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
docker(xui)
1
2
3
4
5
6
mkdir x-ui && cd x-ui
docker run -it --network=host \
-v $PWD/db/:/etc/x-ui/ \
-v $PWD/cert/:/root/cert/ \
--name x-ui --restart=unless-stopped \
enwaiax/x-ui

客户端(Client端)

https://clashforwindows.app/download/

目前 Clash for Windows 最新版本为 v0.20.39,可直接点击下表下载最新版 Clash for Windows。原厂备份,绝无修改,😂笑死根本不会改。

文件名 说明 下载
Clash.for.Windows-0.20.39-arm64-linux.tar.gz Linux ARM 64 位 版本 压缩包 下载
⭐Clash.for.Windows-0.20.39-win.7z Windows 64 位 版本 压缩包 下载
Clash.for.Windows-0.20.39-x64-linux.tar.gz Linux 64 位 版本 压缩包 下载
Clash.for.Windows-0.20.39.dmg Mac 64 位 版本 下载
Clash.for.Windows.Setup.0.20.39.arm64.exe Windows ARM 64 位 版本 下载
⭐Clash.for.Windows.Setup.0.20.39.exe Windows 64 位 版本 下载
Clash.for.Windows.Setup.0.20.39.ia32.exe Windows 英特尔 32 位 版本 下载

美化系统

装个像Mac一样的dock栏

1
sudo pacman -S latte-dock

Screenshot_20231116_172202

点一下Latte下面就会弹出这样的dock(你想多了,没这么好看,你得微调)

Screenshot_20231116_171950

设置桌面动效

娱乐篇

哈哈嗨!说了是娱乐嘛!那肯定得打游戏优先咯。那不得先玩玩fps游戏?

Arch_can_actually_play_games

虚拟化

1.KVM

环境检查
1
2
3
4
5
6
7
8
9
10
# 检查硬件是否支持虚拟化
LC_ALL=C lscpu | grep Virtualization
# 检查内核是否已经包含了支持虚拟化所必须的模块
zgrep CONFIG_KVM /proc/config.gz
# 确定模块是否已经加载
lsmod | grep kvm
# 这里输出中需要包含 virtio
lsmod | grep virtio
# 没有 virtio 时执行
sudo modprobe virtio

Screenshot_20231116_163347Screenshot_20231116_163419Screenshot_20231116_163438

安装KVM

执行下列命令安装必要软件

1
sudo  pacman -S qemu libvirt ovmf virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat
  • qemu QEMU 软件,提供 qemu-img 等命令
  • libvirt 提供管理虚拟机、存储、网络的功能
  • virt-manager, 图形化的管理界面
  • virt-viewer是虚拟机查看器,它是一个显示虚拟化客户机的图形界面的工具
  • dnsmasq DHCP DNS 服务,用于 default NAT 网络
  • bridge-utils 桥接网络管理,用于桥接网络
  • openbsd-netcat 用于通过 SSH 管理
重置虚拟机配置
1
yay -S --noconfirm --needed libguestfs
启动服务
1
2
3
4
# 启动虚拟机管理后台服务
sudo systemctl start libvirtd
# 启动 default NAT 网络
sudo virsh net-start default
设置开机启动
1
2
sudo systemctl enable libvirtd.service
sudo systemctl start libvirtd.service
添加权限组

修改libvirtd.conf文件

1
2
3
4
5
sudo vim /etc/libvirt/libvirtd.conf
# 将UNIX域套接字组所有权设置为libvirt(第85行):
unix_sock_group = "libvirt"
# 设置R/W套接字的UNIX套接字权限(第108行):
unix_sock_rw_perms = "0770"

保存退出,执行下面命令:

1
2
3
4
5
6
#将你的用户帐户添加到libvirt组:
sudo usermod -a -G libvirt $(whoami)
# newgrp 命令使当前普通用户登入到这个群组
newgrp libvirt
# 重启libvirt守护进程:
sudo systemctl restart libvirtd.service
开启嵌套虚拟化

嵌套虚拟化功能使你可以在KVM虚拟机中运行虚拟机,我的CPU是intel的,启用内核模块为kvm_intel,如果是amd的需要改为kvm_amd

1
2
3
4
5
6
7
8
9
10
sudo modprobe -r kvm_intel
sudo modprobe kvm_intel nested=1
要使此配置持久,请运行:
echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf
确认嵌套虚拟化设置为是:
systool -m kvm_intel -v | grep nested
nested = "Y"
nested_early_check = "N"
cat /sys/module/kvm_intel/parameters/nested
Y
创建虚拟机

直接打开virt-manager点点点就行了,这就不用我教了吧!

Screenshot_20231116_165156

这个KVM篇章就是用上面这个虚拟机写的,命令、图片传输只能通过nas传,后续使用VMwareWorkstation就能通过自带的tool加强Linux主机和虚拟机的联系。

2.VMwareWorkstation 篇

vmware-workstation

Screenshot_20231125_164005

3.VirtualBox篇

4.docker篇

一.安装docker
1
sudo pacman -S docker
二.docker基础服务命令

启动docker

1
systemctl start docker

开机启动docker

1
systemctl enable docker

关掉开机启动docker

1
systemclt disable docker

显示docker的版本信息

1
docker version
三.配置镜像加速和docker代理

镜像加速

1
vim /etc/docker/daemon.json

加入这个中科大的源

1
2
3
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

重新加载配置

1
systemctl daemon-reload
1
systemctl restart docker
四.docker命令

查看docker安装的镜像

1
docker images

搜索镜像

1
docker search 目标镜像

下载目标镜像

1
docker pull 目标镜像

下载指定版本的目标镜像

1
docker pull 目标镜像:版本

卸载目标镜像

1
docker rmi -f 容器ID 容器ID 容器ID 容器ID

运行容器

1
2
3
4
5
6
7
8
9
10
docker run [可选参数] image
# 参数说明
--name="Name" Name是你给容器起的名字,来区分容器
-d 后台方式运行
-it 使用交互方式运行,加入容器看内容
-p 指定容器的端口 -p 8080:8080
-p IP:主机端口:容器端口
-p 主机端口:容器端口
-p 容器端口
-P(大P) 随机指定端口

查看正在运行的容器

1
2
3
docker ps
-a #列出当前正在运行的容器+带出历史运行过的容器
-q #列出容器id

退出容器

1
2
exit  #直接容器停止并且退出
ctrl + p + q #容器不停止退出

删除容器

1
2
3
docker rm 容器id      #删除指定的容器,不能删除正在运行发容器 
docker rm -f $(docker ps -aq) #删除所有容器
docker ps -aq | xargs docker rm #删除所有容器

启动和停止容器的操作

1
2
3
4
docker start 容器id   #启动容器
docker restart 容器id #重启容器
docker stop 容器id #停止当前正在运行的容器
docker kill 容器id #强制停止当前容器
五.常用其他命令

后台启动容器

1
2
3
4
docker run -d 镜像名
# 问题docker ps ,发现centos 停止了
#常见的坑,docker容器使用后台运行,就必须要有一个前台进程,docker发现没有应用,就会自动停止
#nginx,容器启动后发现自己没有提供服务,就会立刻停止,就是没有程序了

查看日志目录

1
2
3
docker logs -tf --tail 10 容器id      #看十条容器日志
-tf #显示日志
--tail number #要显示日志条数

查看容器中进程信息

1
docker top 容器id

查看容器的原数据

1
docker inspect 容器id

备份:导出容器数据

1
docker export 容器id > xx.tar

备份:导入备份数据

1
cat xx.tar | docker import - 镜像用户/镜像名:镜像版本号

打包容器成为镜像

1
docker commit -m="提交的描述信息" -a="作者" 容器id 要创建的目标镜像名:[标签名]

进入当前正在运行的容器

1
2
3
4
方式一:进去容器后开启一个新的终端,可以在里面操作(常用)
docker exec -it 容器id /bin/bash
方式二:进入正在运行的终端,不会启动新的进程
docker attach 容器id

拷贝容器里面的数据到主机

1
2
docker cp 容器id:/home/* /home
# 把容器的home目录下的全部文件拷贝到我主机的home目录
部署Mariadb
1
2
3
4
5
6
7
sudo docker run --restart=always --name mariadb01 \ 
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=123456 \
-v /home/orange/docker/mariadb/mysql.conf.d/mysql.cnf:/etc/mysql/mysql.conf.d/mysql.cnf \
-v /home/orange/docker/mariadb/data:/var/lib/mysql \
-d mariadb
#-e环境配置
部署Nginx
1
docker run --name nginx01 -p 8080:80 -v /home/orange/docker/nginx/html:/usr/share/nginx/html:ro -d amd64/nginx
六.docker-compose
WordPress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: '1.18.0'

services:

wordpress:
image: wordpress
restart: always
ports:
- 80:80
- 443:443
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: orange
WORDPRESS_DB_PASSWORD: NNLCV9GG
WORDPRESS_DB_NAME: WordPress
volumes:
- wordpress:/var/www/html

db:
image: mariadb:latest # 更改为使用MariaDB镜像
restart: always
environment:
MYSQL_DATABASE: WordPress
MYSQL_USER: orange
MYSQL_PASSWORD: NNLCV9GG
MYSQL_ROOT_PASSWORD: NNLCV9GG
volumes:
- db:/var/lib/mysql

volumes:
wordpress:
db:

5.wine(最牛的)

HCIA

[toc]

子网计算

image-20230214194022895

image-20230214194423029

习题

1
2
3
4
5
6
7
8
9
4个部门 4个子网
每个部门最多到50台主机 每个子网至少容纳50个主机地址
借两位 主机数=62台
192.168.100.0/24->26

0 1~62 63
64 65~126 127
128 129~190 192
192 193~254 255

image-20230215000603724

块(Block) = 2^主机数位=256-感兴趣掩码数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
如果生产部主机100台,销售部有50台,财务部有25台,客服部有12台,应该如何划分子网呢?

生产部100台,至少保留7位主机位,最多借1位

块=128
生产部可以在下面两个子网二选一,假设选了子网1,那么子网1就不能参与下面其他部门的分割,只能使用子网2去分割。

子网1:192.168.100.0/25
子网2:192.168.100.128/25

销售部50台,至少保留6位主机位,最多借两位
块=64

子网3:192.168.100.128/26
子网4:192.168.100.192/26

销售部25台,客服部有12台,至少保留5位主机位,最多借三位
块=32

子网5:192.168.100.192/27 销售部
子网6:192.168.100.224/27 客服部


第1问:61.179.150.39/28 子网号为多少,广播号为多少,可用IP地址范围是多少?

1
2
3
4
5
6
7
块=16

? X 块 = B < 39
? = 2 B = 32
子网号32
广播号47
可用ip地址范围33 ~ 46

第2问:19.224.17.0/17 可不可以配置在路由器的接口上?如果可以,是为什么,不可以又是为什么?

1
2
3
4
5
块=128

子网地址19.224.0.0/17
19.2240.0~19.224.127.255
可以

第3问:37.95.221.16/5 和 41.222.221.16/5 两个地址在不在同一个网段,能不能ping通?为什么?

1
2
块=8
32.0.0.0/5 40.0.0.0/5 很明显不是同一个网段,ping不通

第4问:给出第3问的IP地址 37.95.221.16的子网号和广播号

1
2
3
4
5
块=128

子网号32.0.0.0/5
广播号39.255.255.255/5
可以

回环网卡设置过程

一.安装过程

1.找到”开始”选项,鼠标右击找到”设备管理器”,然后随便在空白处单击鼠标一下。

屏幕截图(4)

2.鼠标单击菜单栏选项的”操作”选项,然后单击”添加过时硬件”,然后在”弹窗”选项单击”下一步”;在”你想向导做什么”选项里面选择”安装我手动从列表选择的硬件(高级)”,然后单击”下一步”;在”常见硬件类型”选择中选择”网络适配器”,然后单击”下一步”;然后在”厂商”选项中选择”Microsoft”,然后在”型号”选项中选择”Microsoft KM-TEST 环回适配器”,然后单击”下一步“,然后在单击一次”下一步”,系统就会按照选项按照网卡,等待”完成”选项出来后,单击”完成”选项即可完成配置。

屏幕截图(5)

屏幕截图(6)

屏幕截图(7)

屏幕截图(10)

二.检查过程

1.然后可以在”更改适配器选项中”找到”以太网”这张回环网卡

image-20220118203530057

1.当然你也可以给这张网卡”重命名”,比如左上角那张”loop”网卡就是我上一次实验的回环网卡,接下来我会用”loop”网卡做实验(顺带说一句,回环网卡安装好后是必须要重启才能生效)

三.ensp配置回环实验

1.接下来我用这个拓扑来做一次

image-20220118235018574

2.首先,我们单拖一个云”Cloud”出来。然后”右击”鼠标选择”设置”。没开始配置前的设置是这样的,如下图:

image-20220118205140449

3.我们首先在端口创建那里找到绑定信息”UDP”,然后单击右边的”增加”选项。然后,配置表就出现一行配置,如下图:

image-20220118205410999

4.然后我们在端口创建那里找到绑定信息”loop”(我们创建的回环网卡,这里的回环网卡我更改了设备名,所以叫loop),然后单击右边的”增加”选项。然后,配置表就出现第二行配置,如下图:

image-20220118205550165

image-20220118205753084

5.然后我们看下方的”端口映射设置”,在”出”或者”入”端口设置里面选择一方的端口编号设置成为”2”,然后再勾选下方的”双向通道”,然后单击”增加”即可完成配置。

image-20220118210211711

6.设置回环网卡ip为”1.0.0.2”,打开”网络设配器选项”找到目标网卡改就行了

image-20220118210811144

7.给路由器刷入命令(记得开启路由器)

image-20220118211028820

8.xshell测试路由器ip”1.0.0.1”是否可以ping通

image-20220118210928564

9.把服务命令刷入路由器,然后用xshell连接上去。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sys
sys AR1
int g0/0/0
ip add 1.0.0.1 24
q
telnet server enable
user-interface vty 0 4
authentication-mode aaa
q
aaa
local-user julintongxue password cipher 123.com
local-user julintongxue privilege level 15
local-user julintongxue service-type telnet
display this

image-20220118235856933

image-20220118235920804

认证 模式 描述
AAA 登录时需要用户名和密码
Password 登录时只需要密码
1
2
dis telnet server status
dis telnet server enable
命令 备注
user-interface vty 0 4 进入vty配置模式
+ authentication-mode password/aaa 配置认证模式
+ set authentication password cipher huawei 配置认证密码huawei
+ user privilege level 15 配置用户级别为15
user-interface maximum-vty 15 配置最大vty会话数量
aaa 进入aaa配置模式
+ local-user julintongxue password cipher huawei 创建julintongxue用户和huawei密码
+ local-user julintongxue privilege level 15 创建用户级别
+ local-user julintongxue service-type telnet 创建用户可用服务

学习

ospf综合实验

image-20230608003146657

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
sys 
sys AR1
int g0/0/0
ip add 192.168.0.1 24
ospf 1 router-id 1.1.1.1
area 0
net 192.168.0.0 0.0.0.255
int g0/0/0
ospf dr-pri 200



sys
sys AR2
int g0/0/0
ip add 192.168.0.2 24
ospf 1 router-id 2.2.2.2
area 0
net 192.168.0.0 0.0.0.255
int g0/0/0
ospf dr-pri 100



sys
sys AR3
int g0/0/0
ip add 192.168.0.3 24
int s4/0/0
ip add 34.0.0.3 8
ospf authentication-mode md5 1 cipher julintongxue@gmail.com
ospf 1 router-id 3.3.3.3
area 0
net 192.168.0.0 0.0.0.255
net 34.0.0.0 0.255.255.255



sys
sys AR6
int g0/0/0
ip add 192.168.0.6 24
ospf 1 router-id 6.6.6.6
area 0
net 192.168.0.0 0.0.0.255



sys
sys AR4
int g0/0/1
ip add 48.0.0.4 8
ip route-static 0.0.0.0 0 48.0.0.8
int s4/0/0
ip add 34.0.0.4 8
ospf authentication-mode md5 1 cipher julintongxue@gmail.com
int lo 4
ip add 4.4.4.4 32
ospf 1 router-id 4.4.4.4
default-route-advertise
area 0
net 4.4.4.4 0.0.0.0
net 34.0.0.0 0.255.255.255



sys
sys AR5
int g0/0/0
ip add 48.0.0.8 8
ip route-static 0.0.0.0 0 48.0.0.4
int lo 5
ip add 8.8.8.8 32

VLAN“基础实验”

image-20230613001021890

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
sys
sys SW1
vlan batch 10 20 100 200
int g0/0/3
p l t
p t a v 10 20 100 200
int g0/0/1
p l h
p h un v 10 100
p h p v 10
int g0/0/2
p l h
p h un v 20 200
p h p v 20



sys
sys SW2
vlan batch 10 20 100 200
int g0/0/1
p l t
p t a v 10 20 100 200
int g0/0/2
p l t
p t a v 10 20 100 200
int g0/0/3
p l h
p h un v 10 100
p h p v 100
int g0/0/4
p l h
p h un v 20 200
p h p v 200



sys
sys SW3
vlan batch 10 20 100 200
int g0/0/4
p l t
p t a v 10 20 100 200
int g0/0/1
p l h
p h un v 10 100
p h p v 10
int g0/0/2
p l h
p h un v 20 200
p h p v 20

网络安全与管理综合实训

ACl

实验1:ACl

Snipaste_2023-09-07_16-44-36

  • 完成基础配置,让X园区的所有主机都可以访问ISP,完成NAT的配置
  • 要求是AR1和AR2都可以远程R3(SSHv2),但是R1的SSH网管流量在进入ISP是要求被过滤掉
  • 要求X园区的PC1不能访问PC2
  • 要求X园区的HTTP Client1不能访问ISP的HTTP Server1
  • 要求X园区的PC1不能访问ISP的PC3,但是可以访问PC4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
sys 
sys SW1
acl 2000
rule 5 deny source 192.168.1.0 0.0.0.255
int e0/0/2
traffic-filter outbound acl 2000


sys
sys AR1
int g0/0/0
ip add 192.168.1.254 24
int g0/0/1
ip add 100.1.12.1 24
acl 2000
rule permit source 192.168.1.0 0.0.0.255
int g0/0/1
nat outbound 2000
ospf 1
area 1
network 100.1.12.0 0.0.0.255
ssh client first-time enable
acl 3000
rule deny tcp source 192.168.1.3 0 destination 10.10.10.10 0 destination-port eq 80
rule deny icmp source 192.168.1.1 0 destination 8.8.8.8 0
int g0/0/0
traffic-filter inbound acl 3000




sys
sys AR2
int g0/0/0
ip add 100.1.12.254 24
int g0/0/1
ip add 100.1.23.1 24
ospf 1
area 1
network 100.1.23.0 0.0.0.255
network 100.1.12.0 0.0.0.255
ssh client first-time enable
acl 3000
rule deny tcp source 100.1.12.1 0 destination 100.1.23.254 0 destination-port eq 22
int g0/0/0
traffic-filter inbound acl 3000




sys
sys AR3
int g0/0/0
ip add 100.1.23.254 24
int g0/0/1
ip add 8.8.8.254 24
int g0/0/2
ip add 9.9.9.254 24
int g1/0/0
ip add 10.10.10.254 24
ospf 1
area 1
network 8.8.8.0 0.0.0.255
network 9.9.9.0 0.0.0.255
network 10.10.10.0 0.0.0.255
network 100.1.23.0 0.0.0.255
stelnet server enable
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
aaa
local-user orange password cipher huawei@123 privilege level 3
local-user orange service-type ssh
rsa local-key-pair create
ssh user orange authentication-type password

Basic NAT

实验2:Basic_NAT

image-20230913012019405

完成Basic NAT的配置(Easy IP、 地址池 NAT、NAT Server 、静态 NAT/NAPT)

  • PC2访问ISP的8.8.8.8采用G0/0/2 通过静态NAT实现
  • PC3访问ISP的9.9.9.9采用G2/0/0 通过NAPT实现
  • HTTP Client2访问ISP HTTP Server1采用EASYIP实现
  • ISP HTTP Client1访问内网Server2的HTTP服务,通过NAT Server实现
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
NAPT地址池:
101.1.1.11-101.1.1.22



sys
sys AR1
int g0/0/0
ip add 192.168.2.254 24
int g0/0/1
ip add 192.168.1.254 24
int g2/0/1
ip add 102.1.1.1 24
int g0/0/2
ip add 100.1.1.1 24
nat static enable
nat static global 100.1.1.2 inside 192.168.1.1
int g2/0/0
ip add 101.1.1.1 24
ip route-static 0.0.0.0 0 100.1.1.254
ip route-static 9.9.9.9 32 101.1.1.254
ip route-static 10.10.10.10 32 102.1.1.254
nat address-group 1 101.1.1.11 101.1.1.22
acl 2000
rule permit source 192.168.1.2 0.0.0.255
int g2/0/0
nat outbound 2000 address-group 1
acl 2001
rule permit source 192.168.1.3 0
int g2/0/1
nat outbound 2001
int g2/0/1
nat server protocol tcp global current-interface www inside 192.168.2.100 www



sys
sys AR2
int g2/0/0
ip add 8.8.8.254 24
int g2/0/1
ip add 9.9.9.254 24
int g2/0/2
ip add 10.10.10.254 24
int g0/0/2
ip add 102.1.1.254 24
int g0/0/0
ip add 100.1.1.254 24
int g0/0/1
ip add 101.1.1.254 24
ip route-static 100.1.1.2 32 100.1.1.1



sys
sys SW1

NGFW Basic Configuration

实验3:NGFW_Basic_Configuration

  • 防火墙web管理方式实现
  • 防火墙安全区域的规划配置
  • 默认的情况下,Trust的PC1是否能和PC2通讯? 可以通讯
  • 如果Trust的PC1能够PING DMZ的Server1,安全策略如何实现?
  • 如果DMZ的Server1能够PING Trust的PC1,安全策略如何实现?

小云朵连接了回环网卡

这是回环网卡的ip设置

image-20231007022450233

image-20231007021251862

image-20231007021812598

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
sys
sys FW1
int g0/0/0
ip add 192.168.2.1 24
service-manage all permit
firewall zone dmz
add int g1/0/1
int g1/0/1
ip add 172.16.1.254 24
service-manage all permit
firewall zone untrust
add int g1/0/3
int g1/0/3
ip add 100.1.1.1 24
service-manage all permit
firewall zone trust
add int g1/0/2
add int g1/0/0
int g1/0/2
ip add 192.168.2.254 24
service-manage all permit
int g1/0/0
ip add 192.168.1.254 24
service-manage all permit
q
security-policy
rule name PC1-to-200-trust-to-dmz-icmp
source-zone trust
destination-zone dmz
source-address 192.168.1.1 32
destination-address 172.16.1.100 32
service icmp
action permit
q
rule name 200-to-PC1-dmz-to-trust-icmp
source-zone dmz
destination-zone trust
source-address 172.16.1.100 32
destination-address 192.168.1.1 32
service icmp
action permit
q
rule name PC1-to-200-trust-to-dmz-icmp
source-zone trust
destination-zone dmz
source-address 192.168.1.1 32
destination-address 172.16.1.200 32
service icmp
action permit
nat address-group 1
section 130.1.1.1
mode pat
nat-policy
rule name snat-01
source-zone trust
destination-zone dmz
source-address 192.168.1.1 32
destination-address 172.16.1.200 32
service icmp
action source-nat address-group 1




sys
sys AR1
int g0/0/0
ip add 100.1.1.254 24
int g0/0/1
ip add 8.8.8.254 24
int g0/0/2
ip add 9.9.9.254 24
int g4/0/0
ip add 10.10.10.254 24

NGFW NAT Configuration

实验4:NGFW_NAT_Configuration

Server2 又当dnsServer也当httpServer

Server2配置

image-20231007122901911

image-20231007122923090

image-20231007122937350

Client2当客户端image-20231007123023201

image-20231007122623070

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
sys
sys FW1
firewall zone dmz
add int g1/0/1
int g1/0/1
ip add 172.16.1.254 24
service-manage all permit
firewall zone untrust
add int g1/0/3
int g1/0/3
ip add 100.1.1.1 24
service-manage all permit
firewall zone trust
add int g1/0/2
add int g1/0/0
int g1/0/2
ip add 192.168.2.254 24
service-manage all permit
int g1/0/0
ip add 192.168.1.254 24
service-manage all permit
q
security-policy
rule name PC1-PC3-to-PC2-trust-to-untrust
source-zone trust
destination-zone untrust
source-address 192.168.1.1 32
source-address 192.168.2.1 32
destination-address 8.8.8.8 32
service icmp
action permit
nat-policy
rule name EASYIP
source-zone trust
egress-interface g1/0/3
source-address 192.168.0.0 16
destination-address 8.8.8.8 32
service icmp
action source-nat easy-ip
q
q
ip route-static 0.0.0.0 0 100.1.1.254
security-policy
rule name C2-to-S2-to-PC2-untrust-to-trust
source-zone untrust
destination-zone dmz
source-address 9.9.9.9 32
destination-address 172.16.1.200 32
service dns http
action permit
q
q
nat server HTTP1 protocol tcp global 100.1.1.1 8080 inside 172.16.1.200 80
nat server DNS1 protocol udp global 100.1.1.1 53 inside 172.16.1.200 53
dns resolve
dns server 172.16.1.200



sys
sys AR1
int g0/0/0
ip add 100.1.1.254 24
int g0/0/1
ip add 8.8.8.254 24
int g0/0/2
ip add 9.9.9.254 24
int g4/0/0
ip add 10.10.10.254 24

NGFW NAT Server 内网服务器多台映射

实验5:NGFW_NAT_Server内网服务器多台映射

  • 实现将两台服务器都映射到公网上,提供HTTP服务
  • 如果NAT SERVER不同服务器映射到相同的端口,可以实现吗?如果可以是什么现象?

Client1

image-20231007140050878

image-20231007140111661

image-20231007140030346

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
sys
sys AR1
int g0/0/1
ip add 8.8.8.254 24
int g0/0/0
ip add 100.1.1.254 24
ip route-static 0.0.0.0 0 100.1.1.1




sys
sys FW1
firewall zone dmz
add int g1/0/0
int g1/0/0
ip add 172.16.1.254 24
service-manage all permit
firewall zone untrust
add int g1/0/1
int g1/0/1
ip add 100.1.1.1 24
service-manage all permit
q
ip route-static 0.0.0.0 0 100.1.1.254
security-policy
rule name untrust-to-dmz
source-zone untrust
destination-zone dmz
source-address 8.8.8.8 mask 255.255.255.255
destination-address 172.16.1.100 mask 255.255.255.255
destination-address 172.16.1.200 mask 255.255.255.255
service http
service icmp
action permit
q
nat server HTTP1 zone untrust protocol tcp global interface g1/0/1 8081 inside 172.16.1.100 80
nat server HTTP2 zone untrust protocol tcp global interface g1/0/1 8082 inside 172.16.1.200 80

NGFW NAT ALG

实验6:NGFW_NAT_ALG

需求:使用SmartNAT实现FTP应用,分析NAT-ALG在FTP Port模式下的工作过程。

image-20231007164916587

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
sys
sys FW1
int g1/0/0
ip add 172.168.1.254 24
service-manage all permit
firewall zone dmz
add int g1/0/0
int g1/0/1
ip add 100.1.1.1 24
service-manage all permit
firewall zone untrust
add int g1/0/1
ip route-static 0.0.0.0 0 100.1.1.254
security-policy
rule name dmz-to-untrust-ftp01
source-zone dmz
destination-zone untrust
service ftp icmp
action permit
nat address-group 1
mode no-pat global
section 100.1.1.10 100.1.1.20
smart-nopat 100.1.1.21
route enable
nat-policy
rule name smartnat01
source-zone dmz
destination-zone untrust
source-address 172.168.1.100 32
destination-address 8.8.8.8 32
service ftp icmp
action source-nat address-group 1



sys
sys AR1
int g0/0/0
ip add 100.1.1.254 24
int g0/0/1
ip add 8.8.8.254 24

NGFW NAT双出口设计

实验7:NGFW_NAT双出口设计.rar

image-20231014140520912

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
sys
sys FW1
int g1/0/0
ip add 10.3.0.254 24
service-manage all permit
firewall zone trust
add int g1/0/0
int g1/0/2
ip add 1.1.1.1 24
service-manage all permit
firewall zone name isp1
set priority 10
add int g1/0/2
int g1/0/3
ip add 2.2.2.1 24
service-manage all permit
firewall zone name isp2
set priority 11
add int g1/0/3
int g1/0/1
ip add 10.2.0.254 24
service-manage all permit
firewall zone dmz
add int g1/0/1
ip route-static 0.0.0.0 0 1.1.1.2 pre 59
ip route-static 0.0.0.0 0 2.2.2.2
security-policy
rule name trust-to-isp-icmp01
source-zone trust
destination-zone isp1
destination-zone isp2
service icmp
action permit
nat address-group 1
route enable
section 1.1.1.10 1.1.1.20
mode pat
nat address-group 2
route enable
section 2.2.2.10 2.2.2.20
mode pat
nat-policy
rule name sourcenat01
source-zone trust
destination-zone isp1
source-address 10.3.0.0 mask 255.255.255.0
destination-address 8.8.8.0 mask 255.255.255.0
service icmp
action source-nat address-group 1
rule name sourcenat02
source-zone trust
destination-zone isp2
source-address 10.3.0.0 mask 255.255.255.0
destination-address 8.8.8.0 mask 255.255.255.0
service icmp
action source-nat address-group 2
nat server HTTP1 zone isp1 protocol tcp global interface GigabitEthernet1/0/2 www inside 10.2.0.1 www
nat server HTTP2 zone isp2 protocol tcp global interface GigabitEthernet1/0/3 www inside 10.2.0.1 www
security-policy
rule name isp-to-dmz-http01
source-zone isp1
source-zone isp2
destination-zone dmz
service http
action permit


sys
sys AR1
int g0/0/0
ip add 1.1.1.2 24
int g0/0/1
ip add 8.8.8.252 24
vrrp vrid 1 virtual-ip 8.8.8.254
vrrp vrid 1 priority 120
vrrp vrid 1 track interface g0/0/0 reduced 30
dis vrrp brief


sys
sys AR2
int g0/0/0
ip add 2.2.2.2 24
int g0/0/1
ip add 8.8.8.253 24
vrrp vrid 1 virtual-ip 8.8.8.254
dis vrrp brief

NGFW NAT场景规避环路风险的方法

实验8:NGFW_NAT场景规避环路风险的方法

需求:分析上述NAT环境中存在环路风险是什么原因导致,并且提供解决方案?

image-20231007182358503

1
# PC1 tracert 202.1.1.20会环路
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
sys
sys AR1
int g0/0/0
ip add 202.1.1.2 30
int g0/0/1
ip add 210.1.1.1 24
int g0/0/2
ip add 220.1.1.1 24
ip route-static 202.1.1.20 32 202.1.1.1



sys
sys FW1
int g1/0/0
ip add 192.168.0.1 24
service-manage all permit
int g1/0/1
ip add 202.1.1.1 30
service-manage all permit
q
firewall zone trust
add int g1/0/0
q
firewall zone untrust
add int g1/0/1
q
ip route-static 0.0.0.0 0 202.1.1.2
security-policy
rule name trust-to-untrust
source-zone trust
destination-zone untrust
service icmp http
action permit
nat address-group 1
section 202.1.1.10 202.1.1.20
route enable #这个去了就环路
mode pat
nat-policy
rule name sourcenat01
source-zone trust
destination-zone untrust
source-address 192.168.0.0 24
service icmp http
action source-nat address-group 1

#上述环路是因为在AR1里面设置了一条静态路由(ip route-static),该路由的目的是让数据包有回去的方向,但是在Client1 ping 202.1.1.20 的时候,由于FW1本地没有该路由所以交给了缺省路由解决,缺省路由则会把数据交给AR1,而AR1在前面说到有了静态路由,又会把数据丢给FW1,彼此往复就形成环路。
#解决办法则是:在防火墙内设置黑洞路由,把这个会环路的路由丢黑洞里,或者route enable
#dis nat-policy rule all
#dis f s t v

B2B VPN 建设

实验9:B2B_VPN建设.rar

image-20231015131620231

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
sys
sys AR1
int g0/0/0
ip add 192.168.1.254 24
int g0/0/1
ip add 100.1.1.1 24
ip route-static 0.0.0.0 0 100.1.1.2
acl 3000
rule deny ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule permit ip source 192.168.1.0 0.0.0.255
int g0/0/1
nat outbound 3000
acl 3001
rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
ipsec proposal 1
transform ah-esp
ah authentication-algorithm sha2-256
esp authentication-algorithm sha2-256
esp encryption-algorithm 3des
encapsulation-mode tunnel
ipsec policy 1 1 manual
security acl 3001
proposal 1
tunnel local 100.1.1.1
tunnel remote 200.1.1.2
sa spi inbound ah 123456
sa spi inbound esp 123456
sa string-key inbound ah simple 123456
sa string-key inbound esp simple 123456
sa spi outbound ah 654321
sa spi outbound esp 654321
sa string-key outbound ah simple 654321
sa string-key outbound esp simple 654321
q
int g0/0/1
ipsec policy 1




sys
sys AR2-ISP
int g0/0/0
ip add 100.1.1.2 24
int g0/0/1
ip add 200.1.1.1 24
int g0/0/2
ip add 8.8.8.254 24



sys
sys AR3
int g0/0/0
ip add 200.1.1.2 24
int g0/0/1
ip add 192.168.2.254 24
ip route-static 0.0.0.0 0 200.1.1.1
acl 3000
rule deny ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
rule permit ip source 192.168.2.0 0.0.0.255
int g0/0/0
nat outbound 3000
acl 3001
rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
ipsec proposal 1
transform ah-esp
ah authentication-algorithm sha2-256
esp authentication-algorithm sha2-256
esp encryption-algorithm 3des
encapsulation-mode tunnel
ipsec policy 1 1 manual
security acl 3001
proposal 1
tunnel local 200.1.1.2
tunnel remote 100.1.1.1
sa spi inbound ah 654321
sa spi inbound esp 654321
sa string-key inbound ah simple 654321
sa string-key inbound esp simple 654321
sa spi outbound ah 123456
sa spi outbound esp 123456
sa string-key outbound ah simple 123456
sa string-key outbound esp simple 123456
q
int g0/0/0
ipsec policy 1

NGFW GRE TUNNEL Basic Configuration

实验10:NGFW_GRE_TUNNEL_Basic_Configuration.rar

image-20231015172320107

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
sys
sys AR1
int g0/0/0
ip add 100.1.1.254 24
int g0/0/1
ip add 200.1.1.254 24
int g0/0/2
ip add 8.8.8.254 24


sys
sys FW1
firewall zone trust
add int g1/0/0
int g1/0/0
ip add 192.168.1.254 24
service-manage all permit
firewall zone untrust
add int g1/0/1
int g1/0/1
ip add 100.1.1.1 24
service-manage all permit
ip route-static 0.0.0.0 0.0.0.0 100.1.1.254
security-policy
rule name ISP-icmp01
source-zone local
destination-zone untrust
service icmp
action permit
rule name sourcenat01
source-zone trust
destination-zone untrust
service icmp
action permit
nat-policy
rule name sourcenat01
source-zone trust
egress-interface GigabitEthernet1/0/1
source-address 192.168.1.0 mask 255.255.255.0
service icmp
action source-nat easy-ip
int tunnel0
ip add 172.16.1.1 24
tunnel-protocol gre
source 100.1.1.1
destination 200.1.1.1
firewall zone name gre
set priority 10
add interface Tunnel0
security-policy
default action permit
ospf 1
area 0
network 172.16.1.0 0.0.0.255
network 192.168.1.0 0.0.0.255


sys
sys FW2
firewall zone trust
add int g1/0/0
int g1/0/0
ip add 192.168.2.254 24
service-manage all permit
firewall zone untrust
add int g1/0/1
int g1/0/1
ip add 200.1.1.1 24
service-manage all permit
ip route-static 0.0.0.0 0.0.0.0 200.1.1.254
security-policy
rule name ISP-icmp01
source-zone local
destination-zone untrust
service icmp
action permit
rule name sourcenat01
source-zone trust
destination-zone untrust
service icmp
action permit
nat-policy
rule name sourcenat01
source-zone trust
egress-interface GigabitEthernet1/0/1
source-address 192.168.2.0 mask 255.255.255.0
service icmp
action source-nat easy-ip
int tunnel0
ip add 172.16.2.1 24
tunnel-protocol gre
source 200.1.1.1
destination 100.1.1.1
firewall zone name gre
set priority 11
add interface Tunnel0
security-policy
default action permit
ospf 1
area 0
network 172.16.2.0 0.0.0.255
network 192.168.2.0 0.0.0.255

NGFW用户管理和认证部署配置

image-20231015173541524

DHCP中继

image-20230915221920304

image-20230915223928106

  • PC1开dhcp自动获取AR1下发的ip
  • 下面是抓到的报文:

AR1_g0_0_1_DHCP_Unicast.pcapng

AR2_g0_0_0_DHCP_broadcast.pcapng

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sys
sys AR1
dhcp enable
int g0/0/0
ip add 192.168.12.1 24
ip pool 1
network 192.168.1.0 mask 24
gateway-list 192.168.1.254
int g0/0/0
dhcp select global
ip route-static 192.168.1.0 24 192.168.12.2

sys
sys AR2
dhcp enable
int g0/0/1
ip add 192.168.12.2 24
int g0/0/0
ip add 192.168.1.254 24
dhcp select relay
dhcp relay server-ip 192.168.12.1

sys
sys SW1

实验

交换机划分VLAN配置

一、实验目标

1、理解虚拟LAN(VLAN)基本配置;

2、掌握一般交换机按端口划分VLAN的配置方法;

3、掌握Tag VLAN配置方法。

二、实验背景

某一公司内财务部、销售部的PC通过2台交换机实现通信;要求财务部和销售部的PC可以互通,但为了数据安全起见,销售部和财务部需要进行互相隔离,现要在交换机上做适当配置来实现这一目标。

三、技术原理

VLAN是指在一个物理网段内。进行逻辑的划分,划分成若干个虚拟局域网,VLAN做大的特性是不受物理位置的限制,可以进行灵活的划分。VLAN具备了一个物理网段所具备的特性。相同VLAN内的主机可以相互直接通信,不同VLAN间的主机之间互相访问必须经路由设备进行转发,广播数据包只可以在本VLAN内进行广播,不能传输到其他VLAN中。

Port VLAN是实现VLAN的方式之一,它利用交换机的端口进行VALN的划分,一个端口只能属于一个VLAN。
Tag VLAN是基于交换机端口的另一种类型,主要用于是交换机的相同Vlan内的主机之间可以直接访问,同时对不同Vlan的主机进行隔离。Tag VLAN遵循IEEE802.1Q协议的标准,在使用配置了Tag VLAN的端口进行数据传输时,需要在数据帧内添加4个字节的802.1Q标签信息,用于标示该数据帧属于哪个VLAN,便于对端交换机接收到数据帧后进行准确的过滤。

四、实验设备

PC1,PC2,PC3,PC4

两台S5700交换机

五、实验的步骤和结果

image-20221224163323380

结果就是PC1ping通PC3,PC2ping通PC4,PC1和PC3都不能访问PC2和PC4

image-20221224163549970

image-20221224163612934

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# LSW1配置:
sys
sys LSW1
vlan b 10 20
int g0/0/2
p l a
p d v 10
q
int g0/0/3
p l a
p d v 20
q
int g0/0/1
p l t
p t a v 10 20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# LSW2配置:
sys
sys LSW2
vlan b 10 20
int g0/0/2
p l a
p d v 10
q
int g0/0/3
p l a
p d v 20
q
int g0/0/1
p l t
p t a v 10 20

PC1配置(所有的PC只需配ip和子网掩码即可)

image-20221224164203896

三层交换机基本配置

一、实验目标

1、理解三层交换机的基本原理;

2、掌握三层交换机物理端口开启路由功能的配置方法。

二、实验背景

公司现有1台三层交换机,要求你进行测试,该交换机的三层功能是否工作正常。

三、技术原理

三层交换机是带有三层路由功能的交换机,也就是这台交换机的端口既有三层路由功能,也具有二层交换功能。三层交换机端口默认为二层口,如果需要启用三层功能就需要在此端口输入undo portswitch命令。如果切换二层交换机可以用portswitch命令。

四、实验设备

PC1,PC2

一台S5700交换机

五、实验的步骤和结果

讲一下我的设想,PC1和PC2处于不同网段,想要互访必须要经过路由,但是实验只有一个交换机,我们可以使用交换机的三层功能(即套一个路由器,这个路由器是虚拟的,这就是三层路由功能)

image-20230104192525719

交换机配置

1
2
3
4
5
6
7
8
9
10
11
12
13
sys
sys LSW1
vlan batch 10 20
int g0/0/1
p l a
p d v 10
int vlanif10
ip add 192.168.1.254 24
int g0/0/2
p l a
p d v 20
int vlanif20
ip add 192.168.2.254 24

PC配置

image-20230104193842862

image-20230104193858032

利用三层交换机实现VLAN间路由(有问题。。。)

一、实验目标

1、掌握交换机Tag VLAN的配置;
2、掌握三层交换机基本配置方法;
3、掌握三层交换机VLAN路由的配置方法;
4、通过三层交换机实现VLAN间相互通信。

二、实验背景

某企业有两个主要部门,技术部和销售部,分处于不同的办公室,为了安全和便于管理对两个部门的主机进行了VLAN的划分,技术部和销售部分处于不同的VLAN,先由于业务的需求需要销售部和技术部的主机能够相互访问,获得相应的资源,两个部门的交换机通过一台三层交换机进行了连接。

三、技术原理

三层交换机具备网络层的功能,实现VLAN相互访问的原理是:利用三层交换机的路由功能,通过识别数据包的IP地址,查找路由表进行选路转发,三层交换机利用直连路由可以实现不同VLAN之间的相互访问。三层交换机给接口配置IP地址。采用SVI(交换虚拟接口)的方式实现VLAN间互连。SVI是指为交换机中的VLAN创建虚拟接口,并且配置IP地址。

四、实验设备

PC1,PC2,PC3,PC4

两台S5700交换机

五、实验的步骤和结果

image-20230104211928090

交换机LSW1配置

1
2
3
4
5
6
7
8
9
10
11
12
sys
sys LSW1
vlan batch 10 20
int g0/0/1
p l a
p d v 10
int g0/0/2
p l a
p d v 20
int g0/0/3
p l t
p t a v 10 20

交换机LSW2配置

1
2
3
4
5
6
7
8
9
10
11
12
sys
sys LSW2
vlan batch 10 20
int g0/0/1
p l t
p t a v 10 20
int g0/0/2
p l a
p d v 10
int g0/0/3
p l a
p d v 20

PC1配置

image-20230104212214169

PC2配置

image-20230104212226789

PC3配置

image-20230104212237237

PC4配置

image-20230104212252180

我发现这实验有问题的。。。可能是我技术不好,这个更改后的配置,更改前的配置如下:

交换机LSW2配置(其他配置不变)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sys
sys LSW2
vlan batch 10 20
int g0/0/1
p l t
p t a v 10 20
int g0/0/2
p l a
p d v 10
int g0/0/3
p l a
p d v 20
int vlanif 10
ip add 192.168.1.254 24
int vlanif 20
ip add 192.168.2.254 24

我开启了三层功能会发现vlan全部失效,vlan10可以访问vlan20了。。。无奈之下我只能把vlanif的配置去掉,所以上面的配置ping网关全部都是失联的。。。

路由器综合路由配置

一、实验目标

1.掌握中和路由器的配置方法;

2.掌握查看通过路由重分布学习产生的路由;

3.熟悉广域网线缆的链接方式。

二、实验背景

假设某公司通过一台三层交换机连到公司出口路由器 R1上,路由器 R1再和公司外的另一台路由器 R2 连接。三层交换机与 R1 间运行 RIPV2 路由协议,R1与 R2 间运行 OSPF 路由协议。现要做适当配置,实现公司内部主机与公司外部主机之间的相互通信。

三、技术原理

为了支持本设备能够运行多个路由协议进程,系统软件提供了路由信息从一个路由进程重分布到另一个路由进程的功能。比如你可以将 OSPF 路由域的路由重新分布后通高 RIP 路由域中,也可以将 RIP 路由域的路由重新分布后通告到OSPE 路由域中。路由的相互重分布可以在所有的 IP路由协议之间进行。要把路由从一个路由域分布到另一个路由域,并且进行控制路由重分布。

四、实验设备

S5700交换机一台,AR2220路由器两台,PC两台

五、实验的步骤和结果

image-20230104215057099

交换机LSW1配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sys
sys LSW1
v b 10 20
int g0/0/2
p l a
p d v 10
int vlan 10
ip add 192.168.1.1 24
int g0/0/1
p l a
p d v 20
int vlan 20
ip add 192.168.2.1 24
rip
version 2
undo summary
network 192.168.1.0
network 192.168.2.0

AR1配置

1
2
3
4
5
6
7
8
9
10
11
12
13
sys
sys AR1
int g0/0/1
ip add 192.168.2.2 24
int g0/0/0
ip add 192.168.3.1 24
rip
version 2
undo summary
network 192.168.2.0
ospf 1 router-id 1.1.1.1
area 0
network 192.168.3.0 0.0.0.255

AR1路由重分布配置

1
2
3
4
5
rip
import-route ospf
q
ospf 1
import-route rip

AR2配置

1
2
3
4
5
6
7
8
9
10
sys
sys AR2
int g0/0/1
ip add 192.168.3.2 24
int g0/0/0
ip add 192.168.4.1 24
ospf 1 router-id 2.2.2.2
area 0
network 192.168.3.0 0.0.0.255
network 192.168.4.0 0.0.0.255

PC配置

image-20230104215454559

image-20230104215509179

单臂路由

一、实验设备

PC1,PC2

一台S5700交换机和一台AR2220交换机

二、实验的步骤和结果

image-20230101193234867

交换机配置

1
2
3
4
5
6
7
8
9
10
11
12
sys
sys LSW1
vlan batch 10 20
int g0/0/1
p l a
p d v 10
int g0/0/2
p l a
p d v 20
int g0/0/3
p l t
p t a v 10 20

路由器配置

1
2
3
4
5
6
7
8
9
10
sys
sys AR1
int g0/0/0.10 #创建子接口
ip add 192.168.10.254 24
dot1q termination vid 10 #配置子接口终结的VLAN ID
arp broadcast enable #开启子接口的arp广播功能
int g0/0/0.20
ip add 192.168.20.254 24
dot1q termination vid 20
arp broadcast enable

PC配置

image-20230101193316730

image-20230101193332409

单臂路由转三层交换

一、实验设备

PC1,PC2

一台S5700交换机

二、实验的步骤和结果

image-20230101203109624

交换机配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sys
sys LSW1
vlan batch 10 20
int g0/0/1
p l a
p d v 10
int g0/0/2
p l a
p d v 20
int g0/0/3
p l t
p t a v 10 20
int vlanif 10
ip add 192.168.10.254 24
int vlanif 20
ip add 192.168.20.254 24

PC配置

image-20230101193316730

image-20230101193332409

[toc]

1.Nginx 安装

一、安装编译工具及库文件

1
2
3
4
5
#安装编译环境:gcc gcc-c++
#安装openssl-devel(使nginx支持ssl)
#安装lib
yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel

二、首先要安装 PCRE

PCRE 作用是让 Nginx 支持 Rewrite 功能。

1
yum -y install pcre pcre-devel

三、安装 Nginx

1、下载 Nginx,下载地址:https://nginx.org/en/download.html

1
# 找到nginx-1.22.0这个稳定包,下载下来,然后用rz上传到服务器

2、解压安装包

1
tar -xzvf nginx-1.22.0.tar.gz

3、进入安装包目录

1
cd nginx-1.22.0

4、编译

1
./configure --prefix=/usr/local/nginx

5、安装

1
make && make install

6、查看nginx版本

1
/usr/local/nginx/sbin/nginx -v

四、启动Nginx

进入安装好的目录/usr/local/nginx/sbin

1
2
3
4
./nginx           启动
./nginx -s stop 快速关闭
./nginx -s quit 优雅关闭,在退出前完成已经接受的连接请求
./nginx -s reload 重新加载配置

五、关于防火墙和SELINUX

关闭防火墙

1
systemctl stop firewalld.service

禁止防火墙开机自启

1
systemctl stop firewalld.service
1
2
3
4
5
6
7
#关闭SELINUX
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
#修改完成之后重启服务器,然后getenforce看看
#当然如果不想重启服务器也可以先修改好配置,然后用 setenforce 0来临时关闭SELINUX,下次重启自然会识别配置文件了。
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive

六、添加systemctl管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStartPre=/bin/mkdir /tmp/nginx
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF

七、创建环境变量

1
2
3
4
5
vim /etc/profile.d/nginx.sh

NGINX_HOME=/usr/local/nginx
PATH=$NGINX_HOME/sbin:$PATH
export NGINX_HOME PATH

source /etc/profile.d/nginx.sh

启动nginx

1
2
mkdir -p /tmp/nginx
nginx

八、修改ip为静态地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="ff458f3b-f132-400d-ae06-86277ce43612"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.110.131 # 静态ip地址
NETMASK=255.255.255.0 # 子网掩码
GATEWAY=192.168.110.1 # 网关地址
BROADCAST=192.168.110.255 # 广播地址
BOOTPROTO="static" # 修改静态

2.Nginx的conf学习

nginx.conf的配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
more /usr/local/nginx/conf/nginx.conf

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

# 虚拟服务器 这里开始
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# 虚拟服务器 这里结束

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

虚拟主机

虚拟主机应用场景:一个WEB服务器同时发布多个WEB站点

用ip基于端口访问
1
2
3
4
5
6
7
8
9
10
# 在跟目录下放置www目录,然后内置两个目录,分别是www目录和void目录
# 写入不同的html页面
[root@localhost /]# cd www
[root@localhost www]# ls
void www
[root@localhost www]# cat void/index.html
this is void web site...
[root@localhost www]# cat www/index.html
this is www web site...
[root@localhost www]#

修改nginx.conf配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost www]# vim /usr/local/nginx/conf/nginx.conf

server {
listen 80; #网页访问端口80
server_name localhost;
location / {
root /www/www; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81; #网页访问端口81
server_name localhost;
location / {
root /www/void; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
用域名基于端口访问
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost www]# vim /usr/local/nginx/conf/nginx.conf

server {
listen 80; #网页访问端口80
server_name www.julintongxue.top;#域名
location / {
root /www/www; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81; #网页访问端口81
server_name void.julintongxue.top;#域名
location / {
root /www/void; #网址指定目录
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}