ДЭ 2027 — Модули 1–3: задания + Ctrl+C / Ctrl+V
Только задания, готовые команды и проверки. Без теории, пояснений и разбора ошибок.
Команды соответствуют нашему рабочему стенду. Имена Linux-интерфейсов ( enp7s1, enp7s2, enp7s3) перед выполнением сверить через первый блок ip -br link.
МОДУЛЬ 1
ЗАДАНИЕ — Предварительная проверка Linux-машин
Выполнять на: на каждом Linux-устройстве
ПРОВЕРКА:
hostname
ip -br link
ip -4 -br addr
ip routeЗАДАНИЕ — Hostname Linux
Выполнять на: ISP
КОПИПАСТА:
hostnamectl set-hostname ISPВыполнять на: HQ-SRV
КОПИПАСТА:
hostnamectl set-hostname hq-srv.au-team.irpoВыполнять на: HQ-CLI
КОПИПАСТА:
hostnamectl set-hostname hq-cli.au-team.irpoВыполнять на: BR-FW
КОПИПАСТА:
hostnamectl set-hostname br-fw.au-team.irpoВыполнять на: BR-SRV
КОПИПАСТА:
hostnamectl set-hostname br-srv.au-team.irpoЗАДАНИЕ — ISP — адресация и NAT в Интернет
Выполнять на: ISP
КОПИПАСТА:
mkdir -p /etc/net/ifaces/enp7s1 /etc/net/ifaces/enp7s2 /etc/net/ifaces/enp7s3
cat > /etc/net/ifaces/enp7s1/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=dhcp
SYSTEMD_BOOTPROTO=dhcp4
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
cat > /etc/net/ifaces/enp7s2/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '172.16.1.1/28' > /etc/net/ifaces/enp7s2/ipv4address
cat > /etc/net/ifaces/enp7s3/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '172.16.2.1/28' > /etc/net/ifaces/enp7s3/ipv4address
cat > /etc/sysctl.d/99-router.conf <<'EOF'
net.ipv4.ip_forward = 1
EOF
sysctl --system
systemctl restart network
apt-get update
apt-get install -y nftables
systemctl enable --now nftables
mkdir -p /etc/nftables
cat > /etc/nftables/nftables.nft <<'EOF'
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority filter; policy accept;
}
chain forward {
type filter hook forward priority filter; policy accept;
}
chain output {
type filter hook output priority filter; policy accept;
}
}
table ip nat {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 172.16.1.0/28 oifname "enp7s1" masquerade
ip saddr 172.16.2.0/28 oifname "enp7s1" masquerade
}
}
EOF
nft -f /etc/nftables/nftables.nft
nft list ruleset > /etc/nftables.confПРОВЕРКА:
ip -4 -br a
ip route
sysctl net.ipv4.ip_forward
nft list ruleset
ping -c 3 172.16.1.2
ping -c 3 172.16.2.2ЗАДАНИЕ — HQ-RTR — EcoRouter: VLAN, пользователь, GRE, OSPF, NAT, DHCP
Выполнять на: HQ-RTR
КОПИПАСТА:
enable
configure terminal
hostname hq-rtr
ip domain-name au-team.irpo
ip route 0.0.0.0/0 172.16.1.1
interface ISP
ip address 172.16.1.2/28
exit
port ge0
service-instance ge0/ISP
encapsulation untagged
connect ip interface ISP
exit
exit
interface VLAN100
ip address 192.168.100.1/27
exit
interface VLAN200
ip address 192.168.200.1/28
exit
interface VLAN999
ip address 192.168.99.1/29
exit
port ge1
service-instance ge1/VLAN100
encapsulation dot1q 100 exact
rewrite pop 1
connect ip interface VLAN100
exit
service-instance ge1/VLAN200
encapsulation dot1q 200 exact
rewrite pop 1
connect ip interface VLAN200
exit
service-instance ge1/VLAN999
encapsulation dot1q 999 exact
rewrite pop 1
connect ip interface VLAN999
exit
exit
username net_admin
password P@ssw0rd
role admin
exit
interface tunnel.1
ip address 10.10.10.1/30
ip tunnel 172.16.1.2 172.16.2.2 mode gre
exit
router ospf 1
ospf router-id 1.1.1.1
passive-interface default
no passive-interface tunnel.1
network 10.10.10.0/30 area 0
network 192.168.100.0/27 area 0
network 192.168.200.0/28 area 0
network 192.168.99.0/29 area 0
exit
interface tunnel.1
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 P@ssw0rd
exit
interface ISP
ip nat outside
exit
interface VLAN100
ip nat inside
exit
interface VLAN200
ip nat inside
exit
interface VLAN999
ip nat inside
exit
ip nat pool VLAN100 192.168.100.1-192.168.100.30
ip nat pool VLAN200 192.168.200.1-192.168.200.14
ip nat pool VLAN999 192.168.99.1-192.168.99.6
ip nat source dynamic inside-to-outside pool VLAN100 overload interface ISP
ip nat source dynamic inside-to-outside pool VLAN200 overload interface ISP
ip nat source dynamic inside-to-outside pool VLAN999 overload interface ISP
ip pool VLAN200 192.168.200.2-192.168.200.14
dhcp-server 1
pool VLAN200 1
mask 28
gateway 192.168.200.1
dns 192.168.100.2
domain-name au-team.irpo
exit
exit
interface VLAN200
dhcp-server 1
exit
ntp timezone utc+3
write memoryЗАДАНИЕ — BR-RTR — EcoRouter
Выполнять на: BR-RTR
КОПИПАСТА:
enable
configure terminal
hostname br-rtr
ip domain-name au-team.irpo
ip route 0.0.0.0/0 172.16.2.1
interface ISP
ip address 172.16.2.2/28
exit
port ge0
service-instance ge0/ISP
encapsulation untagged
connect ip interface ISP
exit
exit
interface BR-FW
ip address 192.168.77.0/31
exit
port ge1
service-instance ge1/BR-FW
encapsulation untagged
connect ip interface BR-FW
exit
exit
username net_admin
password P@ssw0rd
role admin
exit
interface tunnel.1
ip address 10.10.10.2/30
ip tunnel 172.16.2.2 172.16.1.2 mode gre
exit
router ospf 1
ospf router-id 2.2.2.2
passive-interface default
no passive-interface tunnel.1
no passive-interface BR-FW
network 10.10.10.0/30 area 0
network 192.168.77.0/31 area 0
exit
interface tunnel.1
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 P@ssw0rd
exit
interface ISP
ip nat outside
exit
interface BR-FW
ip nat inside
exit
ip nat pool BR-NET 192.168.77.0-192.168.77.1
ip nat source dynamic inside-to-outside pool BR-NET overload interface ISP
ntp timezone utc+3
write memoryЗАДАНИЕ — BR-FW — адресация, forwarding и OSPF
Выполнять на: BR-FW
КОПИПАСТА:
mkdir -p /etc/net/ifaces/enp7s1 /etc/net/ifaces/enp7s2
cat > /etc/net/ifaces/enp7s1/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '192.168.77.1/31' > /etc/net/ifaces/enp7s1/ipv4address
echo 'default via 192.168.77.0' > /etc/net/ifaces/enp7s1/ipv4route
cat > /etc/net/ifaces/enp7s2/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '192.168.0.1/28' > /etc/net/ifaces/enp7s2/ipv4address
cat > /etc/sysctl.d/99-router.conf <<'EOF'
net.ipv4.ip_forward = 1
EOF
sysctl --system
systemctl restart network
apt-get update
apt-get install -y frr
if [ -f /etc/frr/daemons ]; then
sed -i 's/^zebra=no/zebra=yes/' /etc/frr/daemons
sed -i 's/^ospfd=no/ospfd=yes/' /etc/frr/daemons
fi
systemctl enable --now frrКОПИПАСТА:
vtysh
configure terminal
interface enp7s1
no ip ospf passive
exit
router ospf
ospf router-id 77.7.7.7
passive-interface default
no passive-interface enp7s1
network 192.168.77.0/31 area 0
network 192.168.0.0/28 area 0
exit
end
write memory
exitПРОВЕРКА:
ip -4 -br a
ip route
sysctl net.ipv4.ip_forward
vtysh -c 'show ip ospf neighbor'
vtysh -c 'show ip route ospf'ЗАДАНИЕ — HQ-SRV — сеть, sshuser, SSH, DNS
Выполнять на: HQ-SRV
КОПИПАСТА:
mkdir -p /etc/net/ifaces/enp7s1
cat > /etc/net/ifaces/enp7s1/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '192.168.100.2/27' > /etc/net/ifaces/enp7s1/ipv4address
echo 'default via 192.168.100.1' > /etc/net/ifaces/enp7s1/ipv4route
systemctl restart network
id sshuser >/dev/null 2>&1 || useradd -u 2027 sshuser
echo 'sshuser:P@ssw0rd' | chpasswd
usermod -aG wheel sshuser
cat > /etc/sudoers.d/sshuser <<'EOF'
sshuser ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/sshuser
visudo -c
cp -a /etc/openssh/sshd_config /etc/openssh/sshd_config.before-de2027 2>/dev/null || true
cat > /etc/openssh/sshd_config <<'EOF'
Port 2027
PermitRootLogin no
PasswordAuthentication yes
UsePAM yes
AllowUsers sshuser
MaxAuthTries 2
Banner /etc/openssh/banner
EOF
echo 'Authorized access only' > /etc/openssh/banner
sshd -t
systemctl enable --now sshd
systemctl restart sshd
apt-get update
apt-get install -y dnsmasq
cat > /etc/dnsmasq.conf <<'EOF'
no-hosts
server=77.88.8.8
server=77.88.8.3
cache-size=1000
all-servers
no-negcache
interface=*
host-record=hq-rtr.au-team.irpo,192.168.100.1
host-record=br-rtr.au-team.irpo,192.168.77.0
host-record=br-fw.au-team.irpo,192.168.77.1
host-record=hq-srv.au-team.irpo,192.168.100.2
host-record=hq-cli.au-team.irpo,192.168.200.2
host-record=br-srv.au-team.irpo,192.168.0.2
address=/docker.au-team.irpo/172.16.1.1
address=/web.au-team.irpo/172.16.2.1
EOF
dnsmasq --test
systemctl enable --now dnsmasq
systemctl restart dnsmasq
cat > /etc/resolv.conf <<'EOF'
search au-team.irpo
nameserver 127.0.0.1
EOF
timedatectl set-timezone Europe/MoscowЗАДАНИЕ — BR-SRV — сеть и SSH
Выполнять на: BR-SRV
КОПИПАСТА:
mkdir -p /etc/net/ifaces/enp7s1
cat > /etc/net/ifaces/enp7s1/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
EOF
echo '192.168.0.2/28' > /etc/net/ifaces/enp7s1/ipv4address
echo 'default via 192.168.0.1' > /etc/net/ifaces/enp7s1/ipv4route
systemctl restart network
cat > /etc/resolv.conf <<'EOF'
search au-team.irpo
nameserver 192.168.100.2
EOF
id sshuser >/dev/null 2>&1 || useradd -u 2027 sshuser
echo 'sshuser:P@ssw0rd' | chpasswd
usermod -aG wheel sshuser
cat > /etc/sudoers.d/sshuser <<'EOF'
sshuser ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/sshuser
visudo -c
cp -a /etc/openssh/sshd_config /etc/openssh/sshd_config.before-de2027 2>/dev/null || true
cat > /etc/openssh/sshd_config <<'EOF'
Port 2027
PermitRootLogin no
PasswordAuthentication yes
UsePAM yes
AllowUsers sshuser
MaxAuthTries 2
Banner /etc/openssh/banner
EOF
echo 'Authorized access only' > /etc/openssh/banner
sshd -t
systemctl enable --now sshd
systemctl restart sshd
timedatectl set-timezone Europe/MoscowЗАДАНИЕ — HQ-CLI — DHCP
Выполнять на: HQ-CLI
КОПИПАСТА:
mkdir -p /etc/net/ifaces/enp7s1
rm -f /etc/net/ifaces/enp7s1/ipv4address /etc/net/ifaces/enp7s1/ipv4route
cat > /etc/net/ifaces/enp7s1/options <<'EOF'
TYPE=eth
DISABLED=no
BOOTPROTO=dhcp
SYSTEMD_BOOTPROTO=dhcp4
CONFIG_IPV4=yes
SYSTEMD_CONTROLLED=no
NM_CONTROLLED=no
EOF
systemctl restart network
timedatectl set-timezone Europe/MoscowПРОВЕРКИ МОДУЛЯ
ПРОВЕРКА — HQ-CLI — DHCP, DNS, маршрутизация
ПРОВЕРКА:
echo '===== ADDRESS ====='
ip -4 -br a
echo '===== ROUTE ====='
ip route
echo '===== DNS ====='
cat /etc/resolv.conf
getent hosts hq-srv.au-team.irpo
getent hosts br-srv.au-team.irpo
getent hosts web.au-team.irpo
getent hosts docker.au-team.irpo
echo '===== PING ====='
ping -c 2 192.168.200.1
ping -c 2 192.168.100.2
ping -c 2 192.168.0.2ПРОВЕРКА — HQ-RTR / BR-RTR — GRE и OSPF
ПРОВЕРКА:
show ip interface brief
show ip route
show ip ospf neighbor
show ip ospf interfaceПРОВЕРКА:
show running-config | include tunnel
show running-config | include dhcpПРОВЕРКА — BR-FW
ПРОВЕРКА:
vtysh -c 'show ip ospf neighbor'
vtysh -c 'show ip route ospf'
ping -c 2 192.168.77.0
ping -c 2 192.168.100.2ПРОВЕРКА — SSH с ISP
ПРОВЕРКА:
ssh -p 2027 sshuser@172.16.1.2
ssh -p 2027 sshuser@172.16.2.2ПРОВЕРКА:
Authorized access onlyПРОВЕРКА:
id sshuser
su - sshuser -c 'sudo -n whoami'
sshd -T | grep -E '^(port|maxauthtries|banner|passwordauthentication)'ПРОВЕРКА — Интернет
ПРОВЕРКА:
ping -c 3 77.88.8.8
curl -I --max-time 10 http://example.com 2>/dev/null | headМОДУЛЬ 2
ЗАДАНИЕ — BR-SRV — Samba AD DC
КОПИПАСТА:
apt-get update
apt-get install -y task-samba-dc krb5-kinit
systemctl disable --now smb nmb winbind 2>/dev/null || true
cp -a /etc/samba /root/samba-before-provision 2>/dev/null || true
rm -f /etc/samba/smb.conf
rm -rf /var/lib/samba /var/cache/samba
mkdir -p /var/lib/samba/sysvol
samba-tool domain provision \
--realm=AU-TEAM.IRPO \
--domain=AU-TEAM \
--server-role=dc \
--dns-backend=SAMBA_INTERNAL \
--adminpass='P@ssw0rd' \
--option='dns forwarder = 77.88.8.8'
cp -f /var/lib/samba/private/krb5.conf /etc/krb5.conf
cat > /etc/resolv.conf <<'EOF'
search au-team.irpo
nameserver 127.0.0.1
EOF
systemctl enable --now samba
systemctl restart samba
sleep 3КОПИПАСТА:
samba-tool domain passwordsettings set --min-pwd-length=8
samba-tool domain passwordsettings set --account-lockout-threshold=5
samba-tool domain passwordsettings set --account-lockout-duration=30
samba-tool domain passwordsettings set --reset-account-lockout-after=30
samba-tool group show hq >/dev/null 2>&1 || samba-tool group add hq
for i in 1 2 3 4 5; do
samba-tool user show hquser$i >/dev/null 2>&1 || \
samba-tool user create hquser$i 'P@ssw0rd'
samba-tool user setexpiry hquser$i --noexpiry
samba-tool group addmembers hq hquser$i 2>/dev/null || true
doneПРОВЕРКА:
systemctl is-active samba
samba-tool domain info 127.0.0.1
samba-tool domain passwordsettings show
samba-tool user list
samba-tool group listmembers hq
nslookup br-srv.au-team.irpo 127.0.0.1
nslookup -type=SRV _ldap._tcp.au-team.irpo 127.0.0.1ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
Minimum password length: 8
Account lockout duration (mins): 30
Account lockout threshold (attempts): 5
Reset account lockout after (mins): 30ЗАДАНИЕ — HQ-CLI — ввод в домен AU-TEAM.IRPO
КОПИПАСТА:
cp -a /etc/resolv.conf /root/resolv.conf.before-ad
cat > /etc/resolv.conf <<'EOF'
search au-team.irpo
nameserver 192.168.0.2
EOF
apt-get update
apt-get install -y task-auth-ad-sssd libnss-role krb5-kinit samba-client
system-auth write ad au-team.irpo hq-cli AU-TEAM Administrator 'P@ssw0rd'
systemctl enable sssd
systemctl restart sssd
sleep 3
net ads testjoin
systemctl is-active sssd
getent passwd hquser1
getent group hq
id hquser1ПРОВЕРКА:
systemctl restart network
cat /etc/resolv.confЗАДАНИЕ — HQ-CLI — ограниченный sudo для группы hq
КОПИПАСТА:
control libnss-role enabled
roleadd hq wheel 2>/dev/null || true
rm -f /etc/sudoers.d/hq_group
cat > /etc/sudoers.d/hq-limited <<'EOF'
%hq ALL=(ALL:ALL) NOPASSWD: /bin/cat, /bin/grep, /usr/bin/id
EOF
chmod 0400 /etc/sudoers.d/hq-limited
visudo -c
rolelst 2>/dev/null || trueПРОВЕРКА:
su - hquser1 -c 'sudo -n /usr/bin/id'
su - hquser1 -c 'sudo -n /bin/cat /etc/hostname'
su - hquser1 -c 'sudo -n /bin/bash -c id' && echo ERROR || echo 'OK: bash denied'ЗАДАНИЕ — HQ-SRV — RAID0
КОПИПАСТА:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTSКОПИПАСТА:
apt-get update
apt-get install -y mdadm
mdadm --create /dev/md0 \
--level=0 \
--raid-devices=2 \
/dev/sdb /dev/sdc
mkdir -p /etc/mdadm
mdadm --detail --scan > /etc/mdadm.conf
mkfs.ext4 -F /dev/md0
mkdir -p /raid
RAID_UUID=$(blkid -s UUID -o value /dev/md0)
grep -q "$RAID_UUID" /etc/fstab || \
echo "UUID=$RAID_UUID /raid ext4 defaults 0 0" >> /etc/fstab
mount -aПРОВЕРКА:
cat /proc/mdstat
mdadm --detail /dev/md0
findmnt /raid
df -hT /raidЗАДАНИЕ — HQ-SRV — NFS-сервер
КОПИПАСТА:
apt-get update
apt-get install -y nfs-server nfs-utils
mkdir -p /raid/nfs
chmod 777 /raid/nfs
cat > /etc/exports <<'EOF'
/raid/nfs 192.168.200.0/28(rw,sync,no_subtree_check,no_root_squash)
EOF
systemctl enable --now nfs-server
exportfs -ravПРОВЕРКА:
exportfs -v
showmount -e 127.0.0.1ЗАДАНИЕ — HQ-CLI — NFS-клиент
КОПИПАСТА:
apt-get update
apt-get install -y nfs-utils nfs-clients
mkdir -p /mnt/nfs
grep -q '^192\.168\.100\.2:/raid/nfs ' /etc/fstab || \
echo '192.168.100.2:/raid/nfs /mnt/nfs nfs defaults,_netdev 0 0' >> /etc/fstab
mount -a
printf 'NFS write test %s\n' "$(date -Is)" > /mnt/nfs/hq-cli-write-test.txt
cat /mnt/nfs/hq-cli-write-test.txtПРОВЕРКА:
findmnt /mnt/nfs
df -hT /mnt/nfs
ls -l /mnt/nfsЗАДАНИЕ — ISP — Chrony-сервер
Выполнять на: ISP
КОПИПАСТА:
apt-get update
apt-get install -y chrony
cp -a /etc/chrony.conf /etc/chrony.conf.before-de2027 2>/dev/null || true
cat > /etc/chrony.conf <<'EOF'
pool pool.ntp.org iburst minstratum 4
local stratum 5
allow 0.0.0.0/0
makestep 1.0 3
rtcsync
EOF
systemctl enable --now chronyd
systemctl restart chronyd
sleep 5
chronyc sources -v
chronyc trackingЗАДАНИЕ — Chrony-клиенты Linux
Выполнять на: HQ-SRV и HQ-CLI
КОПИПАСТА:
apt-get install -y chrony
cp -a /etc/chrony.conf /etc/chrony.conf.before-de2027 2>/dev/null || true
cat > /etc/chrony.conf <<'EOF'
server 172.16.1.1 iburst
makestep 1.0 3
rtcsync
EOF
systemctl enable --now chronyd
systemctl restart chronyd
sleep 5
chronyc sources -v
chronyc trackingВыполнять на: BR-SRV и BR-FW
КОПИПАСТА:
apt-get install -y chrony
cp -a /etc/chrony.conf /etc/chrony.conf.before-de2027 2>/dev/null || true
cat > /etc/chrony.conf <<'EOF'
server 172.16.2.1 iburst
makestep 1.0 3
rtcsync
EOF
systemctl enable --now chronyd
systemctl restart chronyd
sleep 5
chronyc sources -v
chronyc trackingВыполнять на: HQ-RTR
КОПИПАСТА:
enable
configure terminal
ntp timezone utc+3
ntp server 172.16.1.1
write memoryВыполнять на: BR-RTR
КОПИПАСТА:
enable
configure terminal
ntp timezone utc+3
ntp server 172.16.2.1
write memoryПРОВЕРКА:
show ntp status
show ntp timezoneЗАДАНИЕ — BR-SRV — Ansible
КОПИПАСТА:
apt-get update
apt-get install -y ansible sshpass python3-module-pip python3-module-paramiko
mkdir -p /etc/ansible
cat > /etc/ansible/hosts <<'EOF'
[linux]
HQ-SRV ansible_host=192.168.100.2 ansible_user=sshuser ansible_password=P@ssw0rd ansible_port=2027
HQ-CLI ansible_host=192.168.200.2 ansible_user=user ansible_password=resu
[routers]
HQ-RTR ansible_host=172.16.1.2 ansible_user=net_admin ansible_password=P@ssw0rd ansible_connection=network_cli ansible_network_os=ios
BR-RTR ansible_host=172.16.2.2 ansible_user=net_admin ansible_password=P@ssw0rd ansible_connection=network_cli ansible_network_os=ios
[all:vars]
ansible_python_interpreter=/usr/bin/python3
EOF
cat > /etc/ansible/ansible.cfg <<'EOF'
[defaults]
inventory = /etc/ansible/hosts
host_key_checking = False
EOFВыполнять на: HQ-RTR и BR-RTR
КОПИПАСТА:
enable
configure terminal
security none
write memoryПРОВЕРКА:
systemctl enable --now sshd
ss -lntp | grep ':22 'КОПИПАСТА:
cd /etc/ansible
ansible --version
ansible all --list-hosts
ansible all -m ping -f 1ЗАДАНИЕ — BR-SRV — swap перед Docker
КОПИПАСТА:
if ! swapon --show | grep -q '^/swapfile'; then
dd if=/dev/zero of=/swapfile bs=1M count=1024 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
fi
grep -q '^/swapfile ' /etc/fstab || \
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
swapon --show
free -hЗАДАНИЕ — BR-SRV — Docker + testapp
КОПИПАСТА:
apt-get update
apt-get install -y docker-engine docker-compose-v2
systemctl enable --now docker
mkdir -p /mnt/additional
mountpoint -q /mnt/additional || mount /dev/sr0 /mnt/additional
find /mnt/additional/docker -maxdepth 1 -type f -printf '%f\n'
SITE_TAR=$(find /mnt/additional/docker -maxdepth 1 -type f -iname '*site*.tar' | head -1)
DB_TAR=$(find /mnt/additional/docker -maxdepth 1 -type f \
\( -iname '*maria*.tar' -o -iname '*mysql*.tar' \) | head -1)
[ -n "$SITE_TAR" ] || { echo 'site image tar not found'; exit 1; }
[ -n "$DB_TAR" ] || { echo 'database image tar not found'; exit 1; }
docker load -i "$SITE_TAR"
docker load -i "$DB_TAR"
docker images
mkdir -p /root/testapp
cat > /root/testapp/compose.yaml <<'EOF'
services:
database:
container_name: db
image: mariadb:10.11
restart: always
ports:
- "3306:3306"
environment:
MARIADB_USER: test
MARIADB_PASSWORD: P@ssw0rd
MARIADB_DATABASE: testdb
MARIADB_ROOT_PASSWORD: P@ssw0rd
healthcheck:
test: ["CMD-SHELL", "mariadb-admin ping -h localhost -p$$MARIADB_ROOT_PASSWORD || exit 1"]
interval: 5s
timeout: 5s
retries: 5
app:
container_name: testapp
image: site:latest
restart: always
ports:
- "8080:8000"
environment:
DB_HOST: database
DB_PORT: "3306"
DB_NAME: testdb
DB_USER: test
DB_PASS: P@ssw0rd
DB_TYPE: maria
depends_on:
database:
condition: service_healthy
EOF
cd /root/testapp
docker compose up -dПРОВЕРКА:
cd /root/testapp
docker compose ps
docker inspect --format '{{.State.Status}} {{if .State.Health}}{{.State.Health.Status}}{{end}}' db
curl -sS -o /dev/null -w 'GET testapp -> HTTP %{http_code}\n' http://127.0.0.1:8080/ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
db running healthy
GET testapp -> HTTP 200ЗАДАНИЕ — HQ-SRV — веб-приложение + MariaDB
КОПИПАСТА:
apt-get update
apt-get install -y lamp-server
systemctl enable --now mariadb
systemctl enable --now httpd2
mkdir -p /mnt/additional
mountpoint -q /mnt/additional || mount /dev/sr0 /mnt/additional
mariadb <<'SQL'
CREATE DATABASE IF NOT EXISTS webdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER IF NOT EXISTS 'web'@'localhost' IDENTIFIED BY 'P@ssw0rd';
ALTER USER 'web'@'localhost' IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON webdb.* TO 'web'@'localhost';
FLUSH PRIVILEGES;
SQL
DUMP=$(find /mnt/additional/web -maxdepth 1 -type f \( -name '*.sql' -o -name 'dump*' \) | head -1)
[ -n "$DUMP" ] && mariadb -u web -p'P@ssw0rd' webdb < "$DUMP"
cp -f /mnt/additional/web/index.php /var/www/html/index.php
cp -f /mnt/additional/web/logo.png /var/www/html/logo.png
rm -f /var/www/html/index.html
python3 - <<'PY'
from pathlib import Path
import re
p = Path('/var/www/html/index.php')
s = p.read_text(errors='ignore')
replacements = [
(r'(\$(?:servername|server)\s*=\s*)["\'][^"\']*["\']', 'localhost'),
(r'(\$username\s*=\s*)["\'][^"\']*["\']', 'web'),
(r'(\$password\s*=\s*)["\'][^"\']*["\']', 'P@ssw0rd'),
(r'(\$(?:dbname|database)\s*=\s*)["\'][^"\']*["\']', 'webdb'),
]
for pat, value in replacements:
s = re.sub(pat, lambda m, v=value: m.group(1) + '"' + v + '"', s, count=1)
p.write_text(s)
PY
systemctl restart mariadb
systemctl restart httpd2ПРОВЕРКА:
mariadb -u web -p'P@ssw0rd' -e 'SHOW DATABASES; USE webdb; SHOW TABLES;'
curl -sS -o /dev/null -w 'HQ WEB -> HTTP %{http_code}\n' http://127.0.0.1/ЗАДАНИЕ — Статический NAT — HQ-RTR
КОПИПАСТА:
enable
configure terminal
ip nat source static tcp 192.168.100.2 80 172.16.1.2 8080
ip nat source static tcp 192.168.100.2 2027 172.16.1.2 2027
write memoryЗАДАНИЕ — Статический NAT — BR-RTR
КОПИПАСТА:
enable
configure terminal
ip nat source static tcp 192.168.0.2 8080 172.16.2.2 8080
ip nat source static tcp 192.168.0.2 2027 172.16.2.2 2027
write memoryПРОВЕРКА:
curl -sS -o /dev/null -w 'HQ WEB NAT -> %{http_code}\n' http://172.16.1.2:8080/
curl -sS -o /dev/null -w 'BR APP NAT -> %{http_code}\n' http://172.16.2.2:8080/
nc -vz 172.16.1.2 2027
nc -vz 172.16.2.2 2027ЗАДАНИЕ — HQ-CLI — Яндекс Браузер
КОПИПАСТА:
apt-get update
apt-get install -y yandex-browser-stable
rpm -q yandex-browser-stableПРОВЕРКИ МОДУЛЯ
ПРОВЕРКА — BR-SRV
ПРОВЕРКА:
echo '===== SAMBA ====='
systemctl is-active samba
samba-tool domain info 127.0.0.1
samba-tool domain passwordsettings show
samba-tool group listmembers hq
echo '===== ANSIBLE ====='
cd /etc/ansible
ansible all -m ping -f 1
echo '===== DOCKER ====='
systemctl is-active docker
docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
curl -sS -o /dev/null -w 'testapp=%{http_code}\n' http://127.0.0.1:8080/
echo '===== FAILED ====='
SYSTEMD_PAGER=cat systemctl --failed --no-pagerПРОВЕРКА — HQ-SRV
ПРОВЕРКА:
echo '===== RAID ====='
cat /proc/mdstat
mdadm --detail /dev/md0 | grep -E 'Raid Level|State|Active Devices|Working Devices'
findmnt /raid
echo '===== NFS ====='
exportfs -v
echo '===== WEB ====='
curl -sS -o /dev/null -w 'web=%{http_code}\n' http://127.0.0.1/
echo '===== TIME ====='
chronyc sources -v
chronyc trackingПРОВЕРКА — HQ-CLI
ПРОВЕРКА:
echo '===== DOMAIN ====='
net ads testjoin
systemctl is-active sssd
getent passwd hquser1
getent group hq
id hquser1
echo '===== SUDO LIMIT ====='
su - hquser1 -c 'sudo -n /usr/bin/id'
su - hquser1 -c 'sudo -n /bin/bash -c id' && echo ERROR || echo 'OK: bash denied'
echo '===== NFS ====='
findmnt /mnt/nfs
touch /mnt/nfs/final-module2-test
ls -l /mnt/nfs/final-module2-test
rm -f /mnt/nfs/final-module2-test
echo '===== BROWSER ====='
rpm -q yandex-browser-stableПРОВЕРКА — ISP
ПРОВЕРКА:
chronyc sources -v
chronyc tracking
curl -sS -o /dev/null -w 'HQ=%{http_code}\n' http://172.16.1.2:8080/
curl -sS -o /dev/null -w 'BR=%{http_code}\n' http://172.16.2.2:8080/МОДУЛЬ 3
ЗАДАНИЕ — BR-SRV — подготовка Users.csv
Действие: подключить Additional.iso к BR-SRV.
Выполнять на: BR-SRV
КОПИПАСТА:
mkdir -p /mnt/additional
mountpoint -q /mnt/additional || mount /dev/sr0 /mnt/additional
ls -lah /mnt/additional
file /mnt/additional/Users.csv
cp -f /mnt/additional/Users.csv /root/Users.csv
# В нашей ISO исходник читался как однобайтовая западная кодировка + CRLF.
# TRANSLIT помогает убрать диакритику там, где это возможно.
iconv -f ISO-8859-1 -t UTF-8//TRANSLIT /root/Users.csv | tr -d '\r' > /root/Users_fixed.csv
file /root/Users_fixed.csv
head -3 /root/Users_fixed.csvЗАДАНИЕ — BR-SRV — полный import.sh
КОПИПАСТА:
cat > /root/import.sh <<'BASH'
#!/bin/bash
set -u
CSV=/root/Users_fixed.csv
MAP=/root/imported_users.txt
SAMDB=/var/lib/samba/private/sam.ldb
: > "$MAP"
python3 - "$CSV" "$MAP" "$SAMDB" <<'PY'
import csv
import re
import subprocess
import sys
import unicodedata
from pathlib import Path
csv_path, map_path, samdb = sys.argv[1:4]
def run(cmd, check=True, input_text=None):
return subprocess.run(
cmd,
input=input_text,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=check,
)
def ascii_login(text):
text = unicodedata.normalize('NFKD', text)
text = ''.join(c for c in text if not unicodedata.combining(c))
text = text.encode('ascii', 'ignore').decode('ascii')
return re.sub(r'[^a-zA-Z0-9._-]', '', text).lower()
def ldif_escape(v):
return v.replace('\r', ' ').replace('\n', ' ').strip()
created = 0
skipped = 0
failed = 0
with open(csv_path, encoding='utf-8-sig', newline='') as f:
reader = csv.reader(f, delimiter=';')
rows = list(reader)
for n, row in enumerate(rows, 1):
if not row or not any(x.strip() for x in row):
continue
row = [x.strip() for x in row]
# Структура, использованная в Additional.iso:
# first;last;role;phone;ou;street;zip;city;country;pass
if len(row) < 10:
print(f'WARN line {n}: expected >=10 fields, got {len(row)}')
failed += 1
continue
first, last, role, phone, ou, street, postal, city, country, password = row[:10]
# пропуск заголовка
if first.lower() in {'first', 'firstname', 'name', 'имя'} or last.lower() in {'last', 'lastname', 'фамилия'}:
continue
username = ascii_login((first[:1] if first else '') + last)
if not username:
print(f'WARN line {n}: empty username')
failed += 1
continue
# OU
if ou:
r = run(['samba-tool', 'ou', 'create', f'OU={ou}'], check=False)
# ошибка Already exists допустима
exists = run(['samba-tool', 'user', 'show', username], check=False).returncode == 0
if not exists:
cmd = [
'samba-tool', 'user', 'create', username, password,
f'--given-name={first}',
f'--surname={last}',
f'--job-title={role}',
f'--telephone-number={phone}',
]
r = run(cmd, check=False)
if r.returncode != 0:
print(f'ERROR create {username}: {r.stderr.strip()}')
failed += 1
continue
created += 1
else:
skipped += 1
run(['samba-tool', 'user', 'setpassword', username, f'--newpassword={password}'], check=False)
run(['samba-tool', 'user', 'setexpiry', username, '--noexpiry'], check=False)
if ou:
run(['samba-tool', 'user', 'move', username, f'OU={ou}'], check=False)
# Найти фактический DN пользователя
q = run([
'ldbsearch', '-H', samdb,
f'(sAMAccountName={username})', 'dn'
], check=False)
dn = ''
for line in q.stdout.splitlines():
if line.startswith('dn: '):
dn = line[4:].strip()
break
if dn:
display = f'{first} {last}'.strip()
attrs = {
'displayName': display,
'streetAddress': street,
'postalCode': postal,
'l': city,
'co': country,
}
chunks = [f'dn: {dn}', 'changetype: modify']
for key, val in attrs.items():
if not val:
continue
chunks += [f'replace: {key}', f'{key}: {ldif_escape(val)}', '-']
ldif = '\n'.join(chunks).rstrip('-\n') + '\n'
run(['ldbmodify', '-H', samdb], check=False, input_text=ldif)
with open(map_path, 'a', encoding='utf-8') as out:
out.write(f'{username};{first};{last};{ou}\n')
print(f'CREATED={created}')
print(f'SKIPPED={skipped}')
print(f'FAILED={failed}')
PY
BASH
chmod +x /root/import.sh
/root/import.shОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
CREATED=300
SKIPPED=0
FAILED=0ПРОВЕРКА:
python3 - <<'PY'
import csv
with open('/root/Users_fixed.csv', encoding='utf-8-sig', newline='') as f:
rows = [r for r in csv.reader(f, delimiter=';') if r and any(x.strip() for x in r)]
# Если первая строка заголовок — не считаем её пользователем.
if rows and rows[0][0].strip().lower() in {'first','firstname','name','имя'}:
rows = rows[1:]
print('CSV_USERS=', len(rows), sep='')
print('MAP_USERS=', sum(1 for x in open('/root/imported_users.txt', encoding='utf-8') if x.strip()), sep='')
PY
samba-tool user show malexander
samba-tool ou list | sortЗАДАНИЕ — HQ-CLI — проверка импортированного пользователя
ПРОВЕРКА:
systemctl is-active sssd
getent passwd malexander
id malexander
kdestroy 2>/dev/null || true
printf '%s\n' 'P@ssw0rd1' | kinit malexander@AU-TEAM.IRPO
klist
kdestroyЗАДАНИЕ — ISP — первоначальный HTTP reverse proxy
Выполнять на: ISP
КОПИПАСТА:
apt-get update
apt-get install -y nginx
mkdir -p /etc/nginx/sites-available.d /etc/nginx/sites-enabled.d
cat > /etc/nginx/sites-available.d/default.conf <<'EOF'
server {
listen 80;
server_name web.au-team.irpo;
location / {
proxy_pass http://172.16.1.2:8080;
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;
}
}
server {
listen 80;
server_name docker.au-team.irpo;
location / {
proxy_pass http://172.16.2.2:8080;
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
ln -sfn /etc/nginx/sites-available.d/default.conf /etc/nginx/sites-enabled.d/default.conf
nginx -t
systemctl enable --now nginx
systemctl reload nginxПРОВЕРКА:
curl -sS -o /dev/null -w 'WEB=%{http_code}\n' -H 'Host: web.au-team.irpo' http://127.0.0.1/
curl -sS -o /dev/null -w 'DOCKER=%{http_code}\n' -H 'Host: docker.au-team.irpo' http://127.0.0.1/ЗАДАНИЕ — ISP — Basic Auth для web
КОПИПАСТА:
apt-get install -y apache2
htpasswd -bc /etc/nginx/.htpasswd WEB 'P@ssw0rd'
chmod 644 /etc/nginx/.htpasswd
# Apache нужен только ради htpasswd; порт 80 должен остаться у nginx.
systemctl disable --now httpd2 2>/dev/null || true
systemctl disable --now apache2 2>/dev/null || trueКОПИПАСТА:
auth_basic "Restricted area";
auth_basic_user_file /etc/nginx/.htpasswd;КОПИПАСТА:
python3 - <<'PY'
p='/etc/nginx/sites-available.d/default.conf'
s=open(p).read()
needle=''' proxy_set_header X-Forwarded-Proto $scheme;\n'''
replace=''' proxy_set_header X-Forwarded-Proto $scheme;\n auth_basic "Restricted area";\n auth_basic_user_file /etc/nginx/.htpasswd;\n'''
# заменяем только первое вхождение — блок web
s=s.replace(needle, replace, 1)
open(p,'w').write(s)
PY
nginx -t
systemctl reload nginxПРОВЕРКА:
curl -sS -o /dev/null -w 'NOAUTH=%{http_code}\n' -H 'Host: web.au-team.irpo' http://127.0.0.1/
curl -sS -o /dev/null -w 'WRONG=%{http_code}\n' -u 'WEB:wrong' -H 'Host: web.au-team.irpo' http://127.0.0.1/
curl -sS -o /dev/null -w 'RIGHT=%{http_code}\n' -u 'WEB:P@ssw0rd' -H 'Host: web.au-team.irpo' http://127.0.0.1/
curl -sS -o /dev/null -w 'DOCKER=%{http_code}\n' -H 'Host: docker.au-team.irpo' http://127.0.0.1/ЗАДАНИЕ — HQ-SRV — CA и сертификаты
Выполнять на: HQ-SRV
КОПИПАСТА:
apt-get update
apt-get install -y openssl ca-certificates
mkdir -p /root/au-ca/{certs,private,csr,ext}
chmod 700 /root/au-ca/private
openssl genrsa -out /root/au-ca/private/au-team-ca.key 4096
chmod 600 /root/au-ca/private/au-team-ca.key
openssl req -x509 -new -sha256 \
-key /root/au-ca/private/au-team-ca.key \
-days 3650 \
-subj '/C=RU/O=AU-TEAM/OU=IT/CN=AU-TEAM Root CA' \
-out /root/au-ca/certs/au-team-ca.crtКОПИПАСТА:
openssl genrsa -out /root/au-ca/private/web.au-team.irpo.key 2048
openssl req -new -sha256 \
-key /root/au-ca/private/web.au-team.irpo.key \
-subj '/C=RU/O=AU-TEAM/CN=web.au-team.irpo' \
-out /root/au-ca/csr/web.au-team.irpo.csr
cat > /root/au-ca/ext/web.au-team.irpo.ext <<'EOF'
basicConstraints=critical,CA:FALSE
keyUsage=critical,digitalSignature,keyEncipherment
extendedKeyUsage=serverAuth
subjectAltName=DNS:web.au-team.irpo
EOF
openssl x509 -req -sha256 \
-in /root/au-ca/csr/web.au-team.irpo.csr \
-CA /root/au-ca/certs/au-team-ca.crt \
-CAkey /root/au-ca/private/au-team-ca.key \
-CAcreateserial \
-days 30 \
-extfile /root/au-ca/ext/web.au-team.irpo.ext \
-out /root/au-ca/certs/web.au-team.irpo.crtКОПИПАСТА:
openssl genrsa -out /root/au-ca/private/docker.au-team.irpo.key 2048
openssl req -new -sha256 \
-key /root/au-ca/private/docker.au-team.irpo.key \
-subj '/C=RU/O=AU-TEAM/CN=docker.au-team.irpo' \
-out /root/au-ca/csr/docker.au-team.irpo.csr
cat > /root/au-ca/ext/docker.au-team.irpo.ext <<'EOF'
basicConstraints=critical,CA:FALSE
keyUsage=critical,digitalSignature,keyEncipherment
extendedKeyUsage=serverAuth
subjectAltName=DNS:docker.au-team.irpo
EOF
openssl x509 -req -sha256 \
-in /root/au-ca/csr/docker.au-team.irpo.csr \
-CA /root/au-ca/certs/au-team-ca.crt \
-CAkey /root/au-ca/private/au-team-ca.key \
-CAserial /root/au-ca/certs/au-team-ca.srl \
-days 30 \
-extfile /root/au-ca/ext/docker.au-team.irpo.ext \
-out /root/au-ca/certs/docker.au-team.irpo.crt
chmod 600 /root/au-ca/private/*.keyПРОВЕРКА:
openssl verify -CAfile /root/au-ca/certs/au-team-ca.crt /root/au-ca/certs/web.au-team.irpo.crt
openssl verify -CAfile /root/au-ca/certs/au-team-ca.crt /root/au-ca/certs/docker.au-team.irpo.crt
openssl x509 -in /root/au-ca/certs/web.au-team.irpo.crt -noout -subject -issuer -dates -ext subjectAltName
openssl x509 -in /root/au-ca/certs/docker.au-team.irpo.crt -noout -subject -issuer -dates -ext subjectAltNameЗАДАНИЕ — HQ-SRV и HQ-CLI — доверие к CA
Выполнять на: HQ-SRV
КОПИПАСТА:
mkdir -p /etc/pki/ca-trust/source/anchors
cp -f /root/au-ca/certs/au-team-ca.crt /etc/pki/ca-trust/source/anchors/au-team-ca.crt
update-ca-trust
# Удобно передать CA на HQ-CLI через уже работающий NFS.
cp -f /root/au-ca/certs/au-team-ca.crt /raid/nfs/au-team-ca.crtВыполнять на: HQ-CLI
КОПИПАСТА:
mkdir -p /etc/pki/ca-trust/source/anchors
cp -f /mnt/nfs/au-team-ca.crt /etc/pki/ca-trust/source/anchors/au-team-ca.crt
update-ca-trust
ls -l /etc/pki/ca-trust/source/anchors/au-team-ca.crtЗАДАНИЕ — Передача сертификатов на ISP
КОПИПАСТА:
mkdir -p /root/isp-tls
cp -f /root/au-ca/certs/au-team-ca.crt /root/isp-tls/
cp -f /root/au-ca/certs/web.au-team.irpo.crt /root/isp-tls/
cp -f /root/au-ca/private/web.au-team.irpo.key /root/isp-tls/
cp -f /root/au-ca/certs/docker.au-team.irpo.crt /root/isp-tls/
cp -f /root/au-ca/private/docker.au-team.irpo.key /root/isp-tls/
tar -C /root -czf /root/isp-tls.tar.gz isp-tlsКОПИПАСТА:
scp /root/isp-tls.tar.gz root@172.16.1.1:/root/Выполнять на: ISP
КОПИПАСТА:
mkdir -p /etc/nginx/ssl
tar -xzf /root/isp-tls.tar.gz -C /root
cp -f /root/isp-tls/* /etc/nginx/ssl/
chmod 600 /etc/nginx/ssl/*.key
chmod 644 /etc/nginx/ssl/*.crtЗАДАНИЕ — ISP — финальный HTTPS reverse proxy
КОПИПАСТА:
cat > /etc/nginx/sites-available.d/default.conf <<'EOF'
server {
listen 80;
server_name web.au-team.irpo;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name web.au-team.irpo;
ssl_certificate /etc/nginx/ssl/web.au-team.irpo.crt;
ssl_certificate_key /etc/nginx/ssl/web.au-team.irpo.key;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://172.16.1.2:8080;
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;
auth_basic "Restricted area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
server {
listen 80;
server_name docker.au-team.irpo;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name docker.au-team.irpo;
ssl_certificate /etc/nginx/ssl/docker.au-team.irpo.crt;
ssl_certificate_key /etc/nginx/ssl/docker.au-team.irpo.key;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://172.16.2.2:8080;
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
nginx -t
systemctl reload nginx
systemctl is-active nginx
ss -lntp | grep -E ':80 |:443 'ЗАДАНИЕ — HQ-CLI — проверка HTTPS без -k
ПРОВЕРКА:
curl -sS -o /dev/null -w 'WEB HTTP -> %{http_code} %{redirect_url}\n' http://web.au-team.irpo/
curl -sS -o /dev/null -w 'DOCKER HTTP -> %{http_code} %{redirect_url}\n' http://docker.au-team.irpo/
curl -sS -o /dev/null -w 'WEB NO AUTH -> %{http_code}\n' https://web.au-team.irpo/
curl -sS -o /dev/null -w 'WEB AUTH -> %{http_code}\n' -u 'WEB:P@ssw0rd' https://web.au-team.irpo/
curl -sS -o /dev/null -w 'DOCKER -> %{http_code}\n' https://docker.au-team.irpo/ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
WEB HTTP -> 301 https://web.au-team.irpo/
DOCKER HTTP -> 301 https://docker.au-team.irpo/
WEB NO AUTH -> 401
WEB AUTH -> 200
DOCKER -> 200ЗАДАНИЕ — HQ-SRV — Atop с интервалом 7 минут
КОПИПАСТА:
apt-get update
apt-get install -y atop
cp -a /etc/default/atop /etc/default/atop.before-de2027 2>/dev/null || true
cat > /etc/default/atop <<'EOF'
LOGOPTS=""
LOGINTERVAL=420
LOGGENERATIONS=28
LOGPATH=/var/log/atop
EOF
systemctl enable --now atop
systemctl restart atop
sleep 2ПРОВЕРКА:
rpm -q atop
systemctl is-enabled atop
systemctl is-active atop
cat /etc/default/atop
ps aux | grep '[a]top'
ls -lh /var/log/atop/КОПИПАСТА:
/usr/bin/atop -w /var/log/atop/atop_YYYYMMDD 420ЗАДАНИЕ — HQ-SRV — CUPS и виртуальный PDF-принтер
КОПИПАСТА:
apt-get update
apt-get install -y cups cups-pdf
systemctl enable --now cups
cupsctl --remote-any --share-printers
lpadmin -p Cups-PDF -o printer-is-shared=true
lpadmin -d Cups-PDF
systemctl restart cupsПРОВЕРКА:
lpstat -t
lpoptions -p Cups-PDF -l >/dev/null 2>&1 || true
ss -lntp | grep ':631'
grep -A20 -E '<(Default)?Printer Cups-PDF>' /etc/cups/printers.conf | \
grep -E 'Printer|DeviceURI|State|Accepting|Shared'
curl -sS -o /dev/null -w 'CUPS=%{http_code}\n' http://127.0.0.1:631/
curl -sS -o /dev/null -w 'QUEUE=%{http_code}\n' http://127.0.0.1:631/printers/Cups-PDFЗАДАНИЕ — HQ-CLI — удалённый принтер HQ-PDF
КОПИПАСТА:
apt-get update
apt-get install -y cups cups-pdf
systemctl enable --now cups
lpadmin -x HQ-PDF 2>/dev/null || true
lpadmin -p HQ-PDF \
-E \
-v ipp://192.168.100.2:631/printers/Cups-PDF \
-m everywhere
lpadmin -d HQ-PDF
lpstat -t
lpstat -v HQ-PDF
lpstat -dКОПИПАСТА:
printf 'DE 2027 CUPS TEST %s\n' "$(date -Is)" | lp -d HQ-PDF
lpstat -W completed -o HQ-PDF 2>/dev/null || trueКОПИПАСТА:
find /var/spool/cups-pdf -type f -name '*.pdf' -printf '%TY-%Tm-%Td %TH:%TM %s %p\n' 2>/dev/null | tail -20ЗАДАНИЕ — BR-SRV — Ansible PC-INFO
КОПИПАСТА:
mkdir -p /etc/ansible
cp -f /mnt/additional/playbook/get_hostname_address.yml \
/etc/ansible/get_hostname_address.source.yml 2>/dev/null || trueКОПИПАСТА:
cat > /etc/ansible/get_hostname_address.yml <<'EOF'
---
- name: Get hostname and IP address
hosts: HQ-SRV,HQ-CLI
gather_facts: yes
tasks:
- name: Ensure PC-INFO directory exists
file:
path: /etc/ansible/PC-INFO
state: directory
mode: '0755'
delegate_to: localhost
run_once: true
- name: Save hostname and IP
copy:
dest: "/etc/ansible/PC-INFO/{{ ansible_hostname }}.yml"
content: |
Hostname: {{ ansible_hostname }}
IP_Address: {{ ansible_default_ipv4.address }}
mode: '0644'
delegate_to: localhost
EOF
ansible-playbook /etc/ansible/get_hostname_address.yml --syntax-check
ansible-playbook /etc/ansible/get_hostname_address.yml -f 1ПРОВЕРКА:
ls -lah /etc/ansible/PC-INFO
cat /etc/ansible/PC-INFO/hq-srv.yml
cat /etc/ansible/PC-INFO/hq-cli.yml
ansible-playbook /etc/ansible/get_hostname_address.yml -f 1ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
Hostname: hq-srv
IP_Address: 192.168.100.2
Hostname: hq-cli
IP_Address: 192.168.200.2ЗАДАНИЕ — HQ-SRV — Fail2ban для SSH 2027
КОПИПАСТА:
apt-get update
apt-get install -y fail2ban python3-module-systemd
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'EOF'
[sshd]
enabled = true
port = 2027
filter = sshd
backend = systemd
maxretry = 3
findtime = 10m
bantime = 1m
EOF
systemctl enable --now fail2ban
systemctl restart fail2ban
sleep 2ПРОВЕРКА:
systemctl is-active fail2ban
fail2ban-client status
fail2ban-client status sshd
echo -n 'MAXRETRY='; fail2ban-client get sshd maxretry
echo -n 'FINDTIME='; fail2ban-client get sshd findtime
echo -n 'BANTIME='; fail2ban-client get sshd bantimeКОПИПАСТА:
MAXRETRY=3
FINDTIME=600
BANTIME=60ЗАДАНИЕ — Реальный тест Fail2ban с BR-SRV
Выполнять на: BR-SRV
КОПИПАСТА:
for i in 1 2 3; do
echo "===== WRONG LOGIN $i ====="
sshpass -p 'WRONG_PASSWORD' ssh \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=5 \
-p 2027 \
sshuser@192.168.100.2 true || true
doneВыполнять на: HQ-SRV
КОПИПАСТА:
fail2ban-client status sshd
iptables -S 2>/dev/null | grep -i f2b || true
grep -E 'Ban |Unban ' /var/log/fail2ban.log 2>/dev/null | tail -20 || trueКОПИПАСТА:
sleep 65
fail2ban-client status sshd
grep -E 'Ban |Unban ' /var/log/fail2ban.log 2>/dev/null | tail -20 || trueЗАДАНИЕ — Cyber Backup — подготовка HQ-SRV
Действие: подключить Cyber Backup ISO к HQ-SRV.
КОПИПАСТА:
if ! swapon --show | grep -q '^/swapfile'; then
dd if=/dev/zero of=/swapfile bs=1M count=1024 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
fi
grep -q '^/swapfile ' /etc/fstab || \
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
free -h
df -h /КОПИПАСТА:
mkdir -p /mnt/cyberbackup
mountpoint -q /mnt/cyberbackup || mount /dev/sr0 /mnt/cyberbackup
find /mnt/cyberbackup -maxdepth 2 -type f -printf '%p\n'КОПИПАСТА:
INSTALLER=/mnt/cyberbackup/cyberbackup_17.4.36200.x86_64
chmod +x "$INSTALLER"
"$INSTALLER" \
--auto \
--id=AcronisCentralizedManagementServer,BackupAndRecoveryAgent
echo "INSTALL_EXIT_CODE=$?"ПРОВЕРКА:
rpm -qa | grep -E 'AcronisCentralizedManagementServer|BackupAndRecoveryAgent' | sort
for s in \
aakore \
acronis_ams \
acronis_asm \
acronis_mms \
acronis_monitoring_service \
acronis_schedule \
acronis_zmqgw
do
printf '%-35s ' "$s"
systemctl is-active "$s" 2>/dev/null || true
done
ss -lntp | grep -E ':9877|:9850|:9851|:7780' || true
curl -k -sS -o /dev/null -w 'Cyber Backup -> HTTP %{http_code}\n' https://127.0.0.1:9877/ЗАДАНИЕ — Cyber Backup — подразделение irpo и irpoadmin
КОПИПАСТА:
https://192.168.100.2:9877КОПИПАСТА:
irpoКОПИПАСТА:
id irpoadmin >/dev/null 2>&1 || useradd -m -s /bin/bash irpoadmin
echo 'irpoadmin:P@ssw0rd' | chpasswd
cat > /etc/security/acronisagent.conf <<'EOF'
root
irpoadmin
EOF
systemctl restart acronis_ams acronis_asmКОПИПАСТА:
irpoadmin
P@ssw0rdКОПИПАСТА:
cp -a /etc/passwd /root/passwd.before-irpoadmin
cp -a /etc/shadow /root/shadow.before-irpoadmin
cp -a /etc/group /root/group.before-irpoadmin
usermod -o -u 0 -g 0 irpoadmin
getent passwd irpoadmin
id irpoadmin
systemctl restart acronis_ams acronis_asmЗАДАНИЕ — Cyber Backup — подготовка HQ-CLI как Storage Node
Действие: подключить ту же Cyber Backup ISO к HQ-CLI.
Выполнять на: HQ-CLI
КОПИПАСТА:
if ! swapon --show | grep -q '^/swapfile'; then
dd if=/dev/zero of=/swapfile bs=1M count=1024 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
fi
grep -q '^/swapfile ' /etc/fstab || \
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
mkdir -p /backup
chown root:root /backup
chmod 700 /backup
free -h
ls -ld /backupКОПИПАСТА:
mkdir -p /mnt/cyberbackup
mountpoint -q /mnt/cyberbackup || mount /dev/sr0 /mnt/cyberbackup
INSTALLER=/mnt/cyberbackup/cyberbackup_17.4.36200.x86_64
chmod +x "$INSTALLER"
"$INSTALLER" \
--auto \
--id=BackupAndRecoveryAgent,StorageServer \
--rain=192.168.100.2 \
--login=irpoadmin \
--password='P@ssw0rd'
echo "INSTALL_EXIT_CODE=$?"Выполнять на: без —unit“
ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
rpm -qa | grep -E 'BackupAndRecoveryAgent|StorageServer' | sort
for s in aakore acronis_agent acronis_mms acronis_schedule acronis_storageserver; do
printf '%-35s ' "$s"
systemctl is-active "$s" 2>/dev/null || true
done
ss -lntp | grep -E ':9850|:9876' || true
curl -k -sS -o /dev/null -w 'AMS=%{http_code}\n' https://192.168.100.2:9877/ЗАДАНИЕ — Cyber Backup — создание хранилища через GUI
GUI:
Узлы хранения -> проверить hq-cli.au-team.irpo (192.168.200.2)
Добавить хранилище
Name: backup
Storage node: hq-cli.au-team.irpo
Address: hq-cli.au-team.irpo
Path: /backup
Browse agent: hq-cli.au-team.irpo
Если запросит bsp://hq-cli.au-team.irpo/backup/ -> локальные root credentials HQ-CLI
СохранитьКОПИПАСТА:
Name: backup
Storage node: hq-cli.au-team.irpo
Address: hq-cli.au-team.irpo
Path: /backupЗАДАНИЕ — Cyber Backup — план /etc HQ-SRV
GUI:
Устройства -> Все устройства -> hq-srv.au-team.irpo
Включить защиту
Выбор данных: Файлы/папки
Элемент: /etc/
Место сохранения: backup
Применить
Запустить сейчас -> Полная копия
Дождаться: Состояние = OKКОПИПАСТА:
/etc/ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
hq-srv.au-team.irpo
Состояние: OK
Последняя копия: 17.09.2026 06:46:11ЗАДАНИЕ — HQ-CLI — фактическая проверка backup
ПРОВЕРКА:
echo '===== STORAGE SIZE ====='
du -sh /backup
echo '===== ROOT CONTENT ====='
ls -lah /backup
echo '===== FILE COUNT ====='
find /backup -type f 2>/dev/null | wc -l
echo '===== RECENT CONTENT ====='
find /backup \
-maxdepth 4 \
-printf '%TY-%Tm-%Td %TH:%TM:%TS %10s %p\n' \
2>/dev/null | sort | tail -100
echo '===== FILESYSTEM ====='
df -hT /backupОЖИДАЕМЫЙ РЕЗУЛЬТАТ:
/backup = 4.9M
/backup/computers/...
/backup/.meta/...ПРОВЕРКИ МОДУЛЯ
ПРОВЕРКА — Пункт 1 — импорт пользователей
ПРОВЕРКА:
samba-tool user show malexander
samba-tool ou list | sort
wc -l /root/imported_users.txtПРОВЕРКА:
getent passwd malexander
id malexander
printf '%s\n' 'P@ssw0rd1' | kinit malexander@AU-TEAM.IRPO
klist
kdestroyПРОВЕРКА — Пункты 2–4 — proxy, auth, TLS
ПРОВЕРКА:
curl -sS -o /dev/null -w 'WEB HTTP=%{http_code} %{redirect_url}\n' http://web.au-team.irpo/
curl -sS -o /dev/null -w 'DOCKER HTTP=%{http_code} %{redirect_url}\n' http://docker.au-team.irpo/
curl -sS -o /dev/null -w 'WEB NOAUTH=%{http_code}\n' https://web.au-team.irpo/
curl -sS -o /dev/null -w 'WEB AUTH=%{http_code}\n' -u 'WEB:P@ssw0rd' https://web.au-team.irpo/
curl -sS -o /dev/null -w 'DOCKER=%{http_code}\n' https://docker.au-team.irpo/ПРОВЕРКА — Пункт 5 — atop
ПРОВЕРКА:
systemctl is-enabled atop
systemctl is-active atop
grep '^LOGINTERVAL=' /etc/default/atop
ps aux | grep '[a]top'
ls -lh /var/log/atop/ПРОВЕРКА — Пункт 6 — CUPS
ПРОВЕРКА:
lpstat -t
ss -lntp | grep ':631'
grep -A20 -E '<(Default)?Printer Cups-PDF>' /etc/cups/printers.conf | grep SharedПРОВЕРКА:
lpstat -v HQ-PDF
lpstat -d
curl -sS -o /dev/null -w '%{http_code}\n' http://192.168.100.2:631/printers/Cups-PDFПРОВЕРКА — Пункт 7 — Ansible
ПРОВЕРКА:
ansible-playbook /etc/ansible/get_hostname_address.yml --syntax-check
ansible-playbook /etc/ansible/get_hostname_address.yml -f 1
cat /etc/ansible/PC-INFO/hq-srv.yml
cat /etc/ansible/PC-INFO/hq-cli.ymlПРОВЕРКА — Пункт 8 — Fail2ban
ПРОВЕРКА:
fail2ban-client status sshd
fail2ban-client get sshd maxretry
fail2ban-client get sshd bantime
grep -E 'Ban |Unban ' /var/log/fail2ban.log 2>/dev/null | tail -20ПРОВЕРКА — Пункт 9 — Cyber Backup
ПРОВЕРКА:
curl -k -sS -o /dev/null -w '%{http_code}\n' https://127.0.0.1:9877/
rpm -qa | grep -E 'AcronisCentralizedManagementServer|BackupAndRecoveryAgent'ПРОВЕРКА:
rpm -qa | grep -E 'BackupAndRecoveryAgent|StorageServer'
systemctl is-active acronis_storageserver
du -sh /backup
find /backup -type f 2>/dev/null | wc -l