2025年河南省中等职业教育技能大赛网络建设与运维赛项例题(第七套)模块三服务器配置及应用配置答案

2025年河南省中等职业教育技能大赛网络建设与运维赛项例题(第七套)模块三服务器配置及应用配置答案。

从2025年河南省中等职业教育技能大赛网络建设与运维赛项例题(第七套)模块三服务

模块三:服务器配置及应用项目 — 配置答案

所有密码统一为 Pass-1234(题目未指明的默认密码); Windows 管理员及题目未指明密码均为 Pass-1234;Linux root 密码不修改。


一、环境介绍

主机名IP地址网关角色
Windows1.regions.com10.1.211.102/2410.1.211.1域控制器、DHCP、脚本、FTP
Windows2.regions.com10.1.211.103/2410.1.211.1证书颁发机构、DHCP、FTP
Linux1.regions.com10.1.211.112/2410.1.211.1DNS、CA、SSH免密、nginx、nfs
Linux2.regions.com10.1.211.113/2410.1.211.1nfs、SSH、docker

二、Windows 服务配置

(一)域服务配置

任务1:设置IP和主机名

Windows1:

text
# 设置IP(与自动获取的一致)
New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress 10.1.211.102 -PrefixLength 24 -DefaultGateway 10.1.211.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 10.1.211.102

# 设置主机名
Rename-Computer -NewName "Windows1" -Restart

Windows2:

text
New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress 10.1.211.103 -PrefixLength 24 -DefaultGateway 10.1.211.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 10.1.211.102

Rename-Computer -NewName "Windows2" -Restart

任务2:Windows1 配置为域控制器 + DNS

text
# 安装 AD DS 和 DNS 角色
Install-WindowsFeature -Name AD-Domain-Services, DNS -IncludeManagementTools

# 提升为域控制器(新建林)
Install-ADDSForest `
  -DomainName "regions.com" `
  -DomainNetbiosName "REGIONS" `
  -SafeModeAdministratorPassword (ConvertTo-SecureString "Pass-1234" -AsPlainText -Force) `
  -InstallDNS `
  -Force

任务3:域服务迁移到 Windows2,Windows1 降级

Windows2 上操作:

text
# 加入域
Add-Computer -DomainName "regions.com" -Credential (Get-Credential) -Restart

# 安装 AD DS 和 DNS
Install-WindowsFeature -Name AD-Domain-Services, DNS -IncludeManagementTools

# 提升为额外域控制器
Install-ADDSDomainController `
  -DomainName "regions.com" `
  -SafeModeAdministratorPassword (ConvertTo-SecureString "Pass-1234" -AsPlainText -Force) `
  -InstallDNS `
  -Credential (Get-Credential "regions\Administrator") `
  -Force

Windows1 降级为域成员服务器:

text
# 在 Windows1 上操作:转移 FSMO 角色到 Windows2 后降级
Uninstall-ADDSDomainController `
  -LocalAdministratorPassword (ConvertTo-SecureString "Pass-1234" -AsPlainText -Force) `
  -DemoteOperationMasterRole `
  -Force

任务4:Windows2 安装证书服务

text
# 安装证书服务
Install-WindowsFeature -Name AD-Certificate, ADCS-Cert-Authority, ADCS-Web-Enrollment -IncludeManagementTools

# 配置企业根 CA
Install-AdcsCertificationAuthority `
  -CAType EnterpriseRootCA `
  -CACommonName "Windows2.regions.com" `
  -KeyLength 2048 `
  -ValidityPeriod Years `
  -ValidityPeriodUnits 25 `
  -Force

# 安装证书 Web 注册
Install-AdcsWebEnrollment -Force

# 复制证书模板
# 在"证书模板控制台"中,复制"计算机"模板→命名为"计算机模板"
# 配置模板:有效期10年,使用者名称从请求中提供

# 申请证书(通过 certreq 或 Web 注册)
# 证书信息:
# CN = "cert"
# C = CN, S = HeNan, L = ZhengZhou
# O = regions, OU = com
# SAN = *.regions.com, regions.com

certreq.inf 模板文件:

text
[Version]
Signature="$Windows NT$"

[NewRequest]
Subject = "CN=Windows2.regions.com, O=regions, OU=com, L=ZhengZhou, S=HeNan, C=CN"
KeyLength = 2048
Exportable = TRUE
MachineKeySet = TRUE
SMIME = FALSE
PrivateKeyArchive = FALSE
UserProtected = FALSE
UseExistingKeySet = FALSE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
KeyUsage = 0xA0

[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1

[Extensions]
2.5.29.17 = "{text}"
_continue_ = "dns=*.regions.com&"
_continue_ = "dns=regions.com"

任务5:创建组织单元、组和用户


任务6:隐藏 C 盘和 D 盘盘符

组策略 GPO:

text
用户配置 → 管理模板 → Windows 组件 → 文件资源管理器
  "隐藏'我的电脑'中的这些指定的驱动器" → 已启用 → 选择 "C 和 D"

也可以在 GPO 中设置注册表:

text
位置: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
值: NoDrives = 0x0C (C=4, D=8 → 12 = 0x0C)

任务7:禁用注册表编辑器、命令提示符、PowerShell

组策略 GPO:

text
用户配置 → 管理模板 → 系统
  "阻止访问注册表编辑工具" → 已启用 → "是否禁用无提示运行regedit?" → 是

用户配置 → 管理模板 → 系统
  "阻止访问命令提示符" → 已启用 → "是否也禁用命令提示符脚本处理" → 是

!PowerShell 限制可通过 AppLocker 或软件限制策略:
计算机配置 → Windows 设置 → 安全设置 → 软件限制策略
  新建路径规则:%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe → 不允许

任务8:等待网络完全就绪

组策略 GPO:

text
计算机配置 → 管理模板 → 系统 → 登录
  "在计算机启动和登录时总是等待网络" → 已启用

任务9:不自动弹出"服务器管理器"

组策略 GPO:

text
计算机配置 → 管理模板 → Windows 组件 → 服务器管理器
  "登录时不自动显示服务器管理器" → 已启用

任务10:审核账户登录事件

组策略 GPO:

text
计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 审核策略
  "审核账户登录事件" → 已启用 → 勾选"成功"和"失败"

任务11:禁止访问控制面板和系统设置

组策略 GPO:

text
用户配置 → 管理模板 → 控制面板
  "禁止访问'控制面板'和 PC 设置" → 已启用

任务12:禁止 U 盘等可移动存储设备

组策略 GPO:

text
计算机配置 → 管理模板 → 系统 → 设备安装 → 设备安装限制
  "禁止安装可移动设备" → 已启用

或者:
用户配置 → 管理模板 → 系统 → 可移动存储访问
  "所有可移动存储类:拒绝所有访问" → 已启用

任务13:加密数据库修正 — 易受攻击

text
# 适用于 Windows Server,将 CredSSP/TLS 保护设为"易受攻击"
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" `
  -Name "LmCompatibilityLevel" -Value 1 -PropertyType DWORD -Force

# 易受攻击模式指允许较弱的加密协议
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server" `
  -Name "Enabled" -Value 1 -Type DWORD

任务14:漫游用户配置文件

text
# 在 Windows2 上创建共享文件夹
New-Item -Path "D:\Wander" -ItemType Directory
New-SmbShare -Name "Wander" -Path "D:\Wander" -FullAccess "Everyone"

# 为每个用户设置漫游配置文件路径
for ($i = 0; $i -lt 30; $i++) {
    $num = "{0:D2}" -f $i
    Set-ADUser -Identity "Fiance$num" -ProfilePath "\\Windows2\Wander\Fiance$num"
    Set-ADUser -Identity "IT$num" -ProfilePath "\\Windows2\Wander\IT$num"
    Set-ADUser -Identity "HR$num" -ProfilePath "\\Windows2\Wander\HR$num"
}

任务15:关闭所有防火墙

text
# Windows1 和 Windows2
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

(二)DHCP 服务

任务1:DHCP 故障转移集群(负载均衡 1:1)

Windows1:

text
# 安装 DHCP 角色
Install-WindowsFeature -Name DHCP -IncludeManagementTools

# 授权 DHCP 服务器
Add-DhcpServerInDC -DnsName "Windows1.regions.com"

# 创建作用域
Add-DhcpServerv4Scope `
  -Name "regions" `
  -StartRange 10.1.211.10 `
  -EndRange 10.1.211.20 `
  -SubnetMask 255.255.255.0

Set-DhcpServerv4OptionValue `
  -ScopeId 10.1.211.0 `
  -Router 10.1.211.1 `
  -DnsServer 10.1.211.102

Windows2:

text
Install-WindowsFeature -Name DHCP -IncludeManagementTools
Add-DhcpServerInDC -DnsName "Windows2.regions.com"

配置故障转移(负载均衡模式):

text
# 在 Windows1 上操作
Add-DhcpServerv4Failover `
  -Name "regions-failover" `
  -ScopeId 10.1.211.0 `
  -PartnerServer "Windows2.regions.com" `
  -LoadBalancePercent 50 `
  -SharedSecret "Pass-1234" `
  -Force

任务2:创建 IPv4 作用域(已在任务1完成)


任务3:MAC 地址过滤黑名单

text
# 在 DHCP 服务器上拒绝指定 MAC 地址
Add-DhcpServerv4Filter `
  -List Deny `
  -MacAddress "00-1A-2B-CC-DD-EE" `
  -Description "Blocked device 1"

Add-DhcpServerv4Filter `
  -List Deny `
  -MacAddress "AA-BB-CC-DD-EE-FF" `
  -Description "Blocked device 2"

(三)PowerShell 脚本

任务1:创建文件夹和文本文件

text
# 在 Windows1 C:\establish 目录下创建 document01~25,每个含 contentXX.txt

$basePath = "C:\establish"

# 如果目录存在则删除重建
if (Test-Path $basePath) {
    Remove-Item -Path $basePath -Recurse -Force
}
New-Item -Path $basePath -ItemType Directory -Force

for ($i = 1; $i -le 25; $i++) {
    $num = "{0:D2}" -f $i
    $dirPath = Join-Path $basePath "document$num"

    if (Test-Path $dirPath) {
        Remove-Item -Path $dirPath -Recurse -Force
    }
    New-Item -Path $dirPath -ItemType Directory -Force

    $fileName = "content$num.txt"
    $filePath = Join-Path $dirPath $fileName
    Set-Content -Path $filePath -Value "content$num" -Force
}

Write-Host "All 25 directories and files created successfully."

(四)FTP 服务

任务1:创建 FTP 站点 File

text
# 在 Windows1 上安装 FTP 服务和 IIS
Install-WindowsFeature -Name Web-Ftp-Server, Web-Ftp-Service, Web-Ftp-Ext -IncludeManagementTools

# 创建 FTP 站点主目录(指向 Windows2)
# 先在 Windows2 上创建目录并共享

在 Windows2 上:

text
New-Item -Path "D:\Document\Configuration" -ItemType Directory -Force
New-Item -Path "D:\Document\LogFiles" -ItemType Directory -Force
New-SmbShare -Name "FTPConfig" -Path "D:\Document\Configuration"
New-SmbShare -Name "FTPLogs" -Path "D:\Document\LogFiles"

FTP 站点配置(IIS):

text
站点名称: File
物理路径: \\Windows2\FTPConfig
绑定: IP 10.1.211.102,端口 21
SSL: 需要 SSL 连接
身份验证: 基本身份验证(禁用匿名)
日志:
  目录: \\Windows2\FTPLogs
  格式: W3C
  使用本地时间进行文件命名和滚动更新
text
# PowerShell 创建 FTP 站点
Import-Module WebAdministration

# 创建 FTP 站点
New-WebFtpSite `
  -Name "File" `
  -PhysicalPath "\\Windows2.regions.com\FTPConfig" `
  -IPAddress "10.1.211.102" `
  -Port 21

# 禁用匿名
Set-WebConfiguration -Filter "/system.ftpServer/security/authentication/anonymousAuthentication" `
  -Value @{enabled="false"} -PSPath "IIS:\Sites\File"

# 启用基本身份验证
Set-WebConfiguration -Filter "/system.ftpServer/security/authentication/basicAuthentication" `
  -Value @{enabled="true"} -PSPath "IIS:\Sites\File"

# SSL 需要 SSL 连接
Set-WebConfiguration -Filter "/system.ftpServer/security/ssl" `
  -Value @{controlChannelPolicy="SslRequire";dataChannelPolicy="SslRequire"} `
  -PSPath "IIS:\Sites\File"

# 日志配置
Set-WebConfigurationProperty -Filter "/system.applicationHost/sites/site[@name='File']/logFile" `
  -Name "directory" -Value "\\Windows2.regions.com\FTPLogs" `
  -PSPath "IIS:\Sites\File"

Set-WebConfigurationProperty -Filter "/system.applicationHost/sites/site[@name='File']/logFile" `
  -Name "localTimeRollover" -Value $true `
  -PSPath "IIS:\Sites\File"

任务2:FTP 域用户隔离 + HR00/HR01专用文件夹

text
启用 FTP 用户隔离 — 选择"在 Active Directory 中配置 FTP 主目录"模式

# 在 AD 用户属性中设置 FTPRoot 和 FTPDir
# HR00:
#   msIIS-FTPRoot = \\Windows2\FTPConfig
#   msIIS-FTPDir  = HR00
#
# HR01:
#   msIIS-FTPRoot = \\Windows2\FTPConfig
#   msIIS-FTPDir  = HR01

在 Windows2 上创建子文件夹:

text
New-Item -Path "D:\Document\Configuration\HR00" -ItemType Directory -Force
New-Item -Path "D:\Document\Configuration\HR01" -ItemType Directory -Force

# 创建标识文件
Set-Content -Path "D:\Document\Configuration\HR00\HR00.txt" -Value "HR00"
Set-Content -Path "D:\Document\Configuration\HR01\HR01.txt" -Value "HR01"

IIS 配置用户隔离:

text
FTP 站点 → FTP 用户隔离 → "在 Active Directory 中配置 FTP 主目录"

任务3:目录浏览 UNIX 风格 + 禁止上传 .php / .net

text
FTP 站点 → FTP 目录浏览
  目录列表样式: UNIX(U)

FTP 站点 → FTP 请求筛选
  文件扩展名: 拒绝 .php, .net
text
# 设置 UNIX 目录浏览
Set-WebConfiguration -Filter "/system.ftpServer/providerDefinitions/add[@name='dirListing']" `
  -Value "Unix" -PSPath "IIS:\Sites\File"

# 请求筛选 — 禁止 .php 和 .net
Add-WebConfiguration -Filter "/system.ftpServer/security/requestFiltering/fileExtensions" `
  -Value @{fileExtension=".php";allowed="false"} -PSPath "IIS:\Sites\File"

Add-WebConfiguration -Filter "/system.ftpServer/security/requestFiltering/fileExtensions" `
  -Value @{fileExtension=".net";allowed="false"} -PSPath "IIS:\Sites\File"

任务4:连接限制和超时

text
# 最大客户端连接数 1500
Set-WebConfiguration -Filter "/system.ftpServer/serverRuntime" `
  -Value @{maxConnections=1500} -PSPath "IIS:\Sites\File"

# 控制通道超时 120秒 (2分钟)
Set-WebConfiguration -Filter "/system.ftpServer/connections" `
  -Value @{controlChannelTimeout=120} -PSPath "IIS:\Sites\File"

# 数据通道超时 60秒 (1分钟)
Set-WebConfiguration -Filter "/system.ftpServer/connections" `
  -Value @{dataChannelTimeout=60} -PSPath "IIS:\Sites\File"

三、Linux 服务配置

(一)基础环境

任务1:配置 IP 地址和主机名

Linux1:

text
# 使用 nmcli 配置 IP
nmcli con mod ens33 ipv4.addresses 10.1.211.112/24
nmcli con mod ens33 ipv4.gateway 10.1.211.1
nmcli con mod ens33 ipv4.method manual
nmcli con up ens33

# 设置主机名
hostnamectl set-hostname Linux1.regions.com

Linux2:

text
nmcli con mod ens33 ipv4.addresses 10.1.211.113/24
nmcli con mod ens33 ipv4.gateway 10.1.211.1
nmcli con mod ens33 ipv4.method manual
nmcli con up ens33

hostnamectl set-hostname Linux2.regions.com

任务2:配置时区

text
# 两台 Linux 均执行
timedatectl set-timezone Asia/Shanghai

任务3:在 Linux1 指定目录创建文件夹和文件

text
# 根据任务(三)DNS、(四)CA 等要求创建
# 此处根据需要创建对应目录
mkdir -p /var/named
mkdir -p /etc/pki/CA
mkdir -p /etc/pki/tls/certs
mkdir -p /etc/pki/tls/private
mkdir -p /srv/sharenfs
mkdir -p /usr/share/nginx/html

任务4:防火墙配置

text
# 两台 Linux 均执行
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --set-default-zone=public

# Linux1 — 放行服务
firewall-cmd --permanent --add-service=dns
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=ntp
firewall-cmd --permanent --add-port=2049/tcp
firewall-cmd --permanent --add-port=8080/tcp      # tomcat
firewall-cmd --reload

# Linux2 — 放行服务
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=dns
firewall-cmd --permanent --add-port=2049/tcp
firewall-cmd --permanent --add-port=8080/tcp      ! tomcat
firewall-cmd --reload

任务5:SSH 免密登录(root)

text
# 所有 Linux 主机上 root 用户互信
# 在 Linux1 上:
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa

# 复制公钥到本机和 Linux2
ssh-copy-id root@Linux1.regions.com
ssh-copy-id root@Linux2.regions.com

# 在 Linux2 上同样操作:
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
ssh-copy-id root@Linux1.regions.com
ssh-copy-id root@Linux2.regions.com

任务6:定时压缩日志

text
# 在所有 Linux 主机上配置 crontab
mkdir -p /mkdir/tar

# crontab: 每天晚上11点压缩 /var/log/
echo "0 23 * * * tar -czf /mkdir/tar/log.tar.gz /var/log/" | crontab -

任务7:对 /var/log/ 日志压缩

text
# 立即执行一次压缩
tar -czf /mkdir/tar/log.tar.gz /var/log/

(二)chrony — NTP 时间同步

Linux1 配置为 NTP 服务器

text
# 安装 chrony
yum install -y chrony

# 编辑 /etc/chrony.conf(关键配置)
cat > /etc/chrony.conf << 'EOF'
server ntp.aliyun.com iburst
server time1.aliyun.com iburst

# 允许 Linux 子网客户端访问
allow 10.1.211.0/24

# 本地时钟作为备用
local stratum 10

driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
EOF

systemctl restart chronyd
systemctl enable chronyd

Linux2 配置为 NTP 客户端

text
yum install -y chrony

cat > /etc/chrony.conf << 'EOF'
server Linux1.regions.com iburst

driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
EOF

systemctl restart chronyd
systemctl enable chronyd

(三)DNS — BIND

任务1-4:Linux1 主 DNS,Linux2 从 DNS

Linux1 — 主 DNS 服务器:

text
yum install -y bind bind-utils

# 编辑 /etc/named.conf
cat > /etc/named.conf << 'EOF'
options {
    listen-on port 53 { 10.1.211.112; };
    listen-on-v6 port 53 { ::1; };
    directory       "/var/named";
    dump-file       "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";
    allow-query     { 10.1.211.0/24; };
    allow-transfer  { 10.1.211.113; };    ! 允许 Linux2 区域传输

    recursion yes;
    dnssec-enable no;
};

zone "regions.com" IN {
    type master;
    file "named.regions";
    allow-transfer { 10.1.211.113; };
};

zone "211.1.10.in-addr.arpa" IN {
    type master;
    file "named.regions.rev";
    allow-transfer { 10.1.211.113; };
};
EOF

正向解析文件 /var/named/named.regions:

text
cat > /var/named/named.regions << 'EOF'
$TTL 86400
@       IN      SOA     Linux1.regions.com. root.regions.com. (
                        2025052201      ! Serial
                        3600            ! Refresh
                        1800            ! Retry
                        604800          ! Expire
                        86400 )         ! Minimum TTL

@       IN      NS      Linux1.regions.com.
@       IN      NS      Linux2.regions.com.

Linux1  IN      A       10.1.211.112
Linux2  IN      A       10.1.211.113
Windows1 IN     A       10.1.211.102
Windows2 IN     A       10.1.211.103
www     IN      A       10.1.211.112
tomcat  IN      A       10.1.211.112
EOF

反向解析文件 /var/named/named.regions.rev:

text
cat > /var/named/named.regions.rev << 'EOF'
$TTL 86400
@       IN      SOA     Linux1.regions.com. root.regions.com. (
                        2025052201
                        3600
                        1800
                        604800
                        86400 )

@       IN      NS      Linux1.regions.com.
@       IN      NS      Linux2.regions.com.

112     IN      PTR     Linux1.regions.com.
113     IN      PTR     Linux2.regions.com.
102     IN      PTR     Windows1.regions.com.
103     IN      PTR     Windows2.regions.com.
EOF

chmod 640 /var/named/named.regions
chmod 640 /var/named/named.regions.rev
chown root:named /var/named/named.regions
chown root:named /var/named/named.regions.rev

systemctl restart named
systemctl enable named

Linux2 — 从 DNS 服务器:

text
yum install -y bind bind-utils

cat > /etc/named.conf << 'EOF'
options {
    listen-on port 53 { 10.1.211.113; };
    directory       "/var/named";
    allow-query     { 10.1.211.0/24; };
    recursion yes;
    dnssec-enable no;
};

zone "regions.com" IN {
    type slave;
    masters { 10.1.211.112; };
    file "slaves/named.regions";
};

zone "211.1.10.in-addr.arpa" IN {
    type slave;
    masters { 10.1.211.112; };
    file "slaves/named.regions.rev";
};
EOF

systemctl restart named
systemctl enable named

(四)CA 证书服务

任务1:Linux1 配置为 CA 服务器

text
# 创建 CA 目录结构
mkdir -p /etc/pki/CA/{certs,crl,newcerts,private}
touch /etc/pki/CA/index.txt
echo 01 > /etc/pki/CA/serial

# 生成 CA 私钥
openssl genrsa -out /etc/pki/CA/private/ca.key 2048

# 生成 CA 自签名证书(有效期10年)
openssl req -new -x509 -key /etc/pki/CA/private/ca.key \
  -out /etc/pki/CA/ca.crt \
  -days 3650 \
  -subj "/C=CN/ST=HeNan/L=ZhengZhou/O=regions/OU=com/CN=linux1.regions.com"

任务2-4:签发 SSL 证书

text
# 生成服务器私钥
openssl genrsa -out /etc/pki/tls/private/regions.key 2048

# 生成证书请求 CSR
openssl req -new -key /etc/pki/tls/private/regions.key \
  -out /etc/pki/tls/regions.csr \
  -subj "/C=CN/ST=HeNan/L=ZhengZhou/O=regions/OU=system/CN=regions.com"

# 创建扩展文件(含 SAN)
cat > /etc/pki/tls/regions.ext << 'EOF'
subjectAltName = DNS:*.regions.com, DNS:regions.com
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
EOF

# 签发证书(有效期5年)
openssl x509 -req -in /etc/pki/tls/regions.csr \
  -CA /etc/pki/CA/ca.crt \
  -CAkey /etc/pki/CA/private/ca.key \
  -CAcreateserial \
  -out /etc/pki/tls/regions.crt \
  -days 1825 \
  -extfile /etc/pki/tls/regions.ext

# 复制证书和私钥到目标位置
cp /etc/pki/tls/regions.crt /etc/pki/tls/certs/
cp /etc/pki/tls/private/regions.key /etc/pki/tls/

将 CA 证书分发到所有客户端:

text
# 复制到 Linux2
scp /etc/pki/CA/ca.crt root@Linux2:/etc/pki/ca-trust/source/anchors/
ssh root@Linux2 "update-ca-trust"

(五)Nginx + Tomcat + PHP

任务1:Nginx 静态网站 + HTTPS 跳转

Linux2 — 安装 Nginx:

text
yum install -y nginx

# 默认页面
echo "hello nginx" > /usr/share/nginx/html/index.html

# nginx 配置
cat > /etc/nginx/conf.d/regions.conf << 'EOF'
server {
    listen 80;
    server_name regions.com www.regions.com Linux2.regions.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name regions.com www.regions.com Linux2.regions.com;

    ssl_certificate     /etc/pki/tls/regions.crt;
    ssl_certificate_key /etc/pki/tls/private/regions.key;

    root /usr/share/nginx/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
EOF

systemctl restart nginx
systemctl enable nginx

任务2:Nginx 反向代理 Tomcat 负载均衡

Linux1 和 Linux2 — 安装 Tomcat:

text
# 两台都安装
yum install -y java-11-openjdk

# 下载 Tomcat(假设从 D:\soft 获取)
# 手动部署 tomcat 到 /opt/tomcat
# 确保 tomcat 监听 8080 端口

Linux2 — 配置 Nginx 反向代理 + 负载均衡:

text
cat > /etc/nginx/conf.d/tomcat.conf << 'EOF'
upstream tomcat_cluster {
    server 10.1.211.112:8080;
    server 10.1.211.113:8080;
}

server {
    listen 80;
    server_name tomcat.regions.lan;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name tomcat.regions.lan;

    ssl_certificate     /etc/pki/tls/regions.crt;
    ssl_certificate_key /etc/pki/tls/private/regions.key;

    location / {
        proxy_pass http://tomcat_cluster;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
EOF

systemctl restart nginx

任务3:PHP — test.txt 下载

text
# 安装 PHP
yum install -y php php-fpm

# 创建 test.txt
mkdir -p /usr/share/nginx/html
echo "hello php" > /usr/share/nginx/html/test.txt

# nginx 配置,让 .txt 文件直接下载
cat > /etc/nginx/conf.d/php.conf << 'EOF'
server {
    listen 443 ssl;
    server_name regions.com;

    ssl_certificate     /etc/pki/tls/regions.crt;
    ssl_certificate_key /etc/pki/tls/private/regions.key;

    root /usr/share/nginx/html;

    location /test.txt {
        add_header Content-Type text/plain;
        add_header Content-Disposition 'attachment; filename="test.txt"';
    }
}
EOF

systemctl restart nginx

(六)NFS + Kerberos

任务1:配置 KDC 服务器(Linux1)


任务2:创建用户 user007

text
# 在 Linux1 上
groupadd -g 555 user007
useradd -u 555 -g 555 -d /home/userdir -m user007

任务3:配置 Linux1 为 NFS 服务器

text
# 安装 nfs-utils
yum install -y nfs-utils

# 创建共享目录
mkdir -p /srv/sharenfs
chown user007:user007 /srv/sharenfs

# 配置 /etc/exports
cat > /etc/exports << 'EOF'
/srv/sharenfs 10.1.211.0/24(rw,sync,anonuid=555,anongid=555,sec=krb5p)
EOF

# 启用 Kerberos 加密
# sec=krb5p 在 exports 中指定,表示全程加密

exportfs -rav

systemctl restart nfs-server rpcbind
systemctl enable nfs-server rpcbind

任务4:配置 Linux2 为 NFS 客户端 + autofs

text
# 安装 autofs 和 nfs-utils
yum install -y autofs nfs-utils

# 编辑 /etc/auto.master
echo "/- /etc/auto.sharenfs" >> /etc/auto.master

# 创建挂载映射文件 /etc/auto.sharenfs
cat > /etc/auto.sharenfs << 'EOF'
/sharenfs -fstype=nfs,rw,sec=krb5p Linux1.regions.com:/srv/sharenfs
EOF

systemctl restart autofs
systemctl enable autofs

# 验证:访问 /sharenfs 自动挂载,创建 test 目录
ls /sharenfs                     # 触发自动挂载
mkdir /sharenfs/test             # 验证写入权限
ls -la /sharenfs                 # 检查权限

(七)Docker

任务1:安装 Docker 并导入 Rocky 镜像

text
# 在 Linux2 上
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io

systemctl start docker
systemctl enable docker

# 导入 Rocky 镜像(假设 rocky.tar 在 D:\soft 中已复制到 Linux2)
docker load -i /root/rocky.tar

任务2:创建容器 + Apache

text
# 创建名为 regions 的容器,映射 8000→80
docker run -d \
  --name regions \
  -p 8000:80 \
  rocky:latest \
  /bin/bash -c "while true; do sleep 3600; done"

# 进入容器安装 Apache
docker exec -it regions bash -c "
  yum install -y httpd && \
  echo 'Hello Docker' > /var/www/html/index.html && \
  httpd -DFOREGROUND
"

# 或者使用 Dockerfile 方式:
cat > /root/Dockerfile << 'EOF'
FROM rocky:latest
RUN yum install -y httpd
RUN echo "Hello Docker" > /var/www/html/index.html
EXPOSE 80
CMD ["httpd", "-DFOREGROUND"]
EOF

docker build -t regions-apache /root/
docker rm -f regions
docker run -d --name regions -p 8000:80 regions-apache

# 验证
curl http://localhost:8000     # 应输出 "Hello Docker"

说明:以上模块三实操答案。Windows 部分包含 PowerShell 脚本和 GUI 操作指引,Linux 部分为完整命令行配置。实际竞赛中需根据虚拟机环境和软件版本微调。所有密码均为 Pass-1234。如有问题还请联系指点

2025年河南省中等职业教育技能大赛 网络建设与运维赛项(第7套)模块二
河南省第十届御网杯网络安全大赛WP

评论区

评论加载中...