This commit is contained in:
Ваше Имя 2026-05-28 12:49:13 +05:00
parent 9c47ed205f
commit 0f40ff0d02
8 changed files with 171 additions and 50 deletions

View file

@ -15,14 +15,14 @@ Already a pro? Just edit this README.md and make it your own. Want to make it ea
``` ```
cd existing_repo cd existing_repo
git remote add origin http://192.168.0.185/vladmuhamet/net.git git remote add origin http://192.168.0.185/lipina/net.git
git branch -M main git branch -M main
git push -uf origin main git push -uf origin main
``` ```
## Integrate with your tools ## Integrate with your tools
- [ ] [Set up project integrations](http://192.168.0.185/vladmuhamet/net/-/settings/integrations) - [ ] [Set up project integrations](http://192.168.0.185/lipina/net/-/settings/integrations)
## Collaborate with your team ## Collaborate with your team

16
adm
View file

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/bash
# Задание 3, Модуль 1 (HQ-RTR / BR-RTR) # Задание 3, Модуль 1 (HQ-RTR / BR-RTR)
read -p "Введите логин: " L
read -p "Введите пароль: " P
[ $EUID -ne 0 ] && echo "Требуется root" && exit 1 [ $EUID -ne 0 ] && echo "Требуется root" && exit 1
# Пользователь net_admin (маршрутизаторы)
USER="net_admin"
PASS="admin"
# Создание пользователя # Создание пользователя
useradd -m -s /bin/bash "$USER" 2>/dev/null useradd -m -s /bin/bash "$L" 2>/dev/null
echo "$USER:$PASS" | chpasswd echo "$L:$P" | chpasswd
# Sudo без пароля # Sudo без пароля
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers echo "$L ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
chmod 440 /etc/sudoers chmod 440 /etc/sudoers
echo "Готово" echo "Готово"
echo ""
echo "Имя: $L"
echo "Пароль: $P"

89
dhcp
View file

@ -1,15 +1,84 @@
#!/bin/nash #!/bin/bash
read -p "Введите начало диапазона(192.168.4.2): " S
read -p "Введите конец диапазона(192.168.4.6): " K
read -p "Введите подсеть(192.168.4.0): " Q
read -p "Введите маску(29): " E
read -p "Введите dns сервер(192.168.3.2): " R
read -p "Введите шлюз(192.168.4.1): " T
read -p "Введите ip-адрес BR-SRV: " B
if (( $E == 2 )); then
E=192.0.0.0
elif (( $E == 3 )); then
E=224.0.0.0
elif (( $E == 4 )); then
E=240.0.0.0
elif (( $E == 5 )); then
E=248.0.0.0
elif (( $E == 6 )); then
E=252.0.0.0
elif (( $E == 7 )); then
E=254.0.0.0
elif (( $E == 8 )); then
E=255.0.0.0
elif (( $E == 9 )); then
E=255.128.0.0
elif (( $E == 10 )); then
E=255.192.0.0
elif (( $E == 11 )); then
E=255.224.0.0
elif (( $E == 12 )); then
E=255.240.0.0
elif (( $E == 13 )); then
E=255.248.0.0
elif (( $E == 14 )); then
E=255.252.0.0
elif (( $E == 15 )); then
E=255.254.0.0
elif (( $E == 16 )); then
E=255.255.0.0
elif (( $E == 17 )); then
E=255.255.128.0
elif (( $E == 18 )); then
E=255.255.192.0
elif (( $E == 19 )); then
E=255.255.224.0
elif (( $E == 20 )); then
E=252.255.240.0
elif (( $E == 21 )); then
E=255.255.248.0
elif (( $E == 22 )); then
E=255.255.252.0
elif (( $E == 23 )); then
E=255.255.254.0
elif (( $E == 24 )); then
E=224.255.255.0
elif (( $E == 25 )); then
E=255.255.255.128
elif (( $E == 26 )); then
E=255.255.255.192
elif (( $E == 27 )); then
E=255.255.255.224
elif (( $E == 28 )); then
E=255.255.255.240
elif (( $E == 29 )); then
E=255.255.255.248
elif (( $E == 30 )); then
E=255.255.255.252
elif (( $E == 31 )); then
E=255.255.255.254
elif (( $E == 32 )); then
E=255.255.255.255
fi
cat > /etc/dhcp/dhcpd.conf << EOF cat > /etc/dhcp/dhcpd.conf << EOF
default-lease-time 600; default-lease-time 600;
max-lease-time 7200; max-lease-time 7200;
authoritative; authoritative;
subnet 192.168.4.0 netmask 255.255.255.248 { subnet $Q netmask $E {
range 192.168.4.2 192.168.4.6; range $S $K;
option domain-name-servers 192.168.3.2, 8.8.4.4; option domain-name-servers $R, $B;
option subnet-mask 255.255.255.248; option subnet-mask $E;
option routers 172.16.4.1; option routers $T;
} }
@ -17,15 +86,15 @@ host hq-cli {
hardware ethernet hardware ethernet
08:00:27:c7:82:fa; 08:00:27:c7:82:fa;
fixed-address fixed-address
192.168.4.2; $S;
} }
EOF EOF
chmod 600 /etc/dhcp/dhcpd.conf chmod 600 /etc/dhcp/dhcpd.conf
cat > /etc/sysconfig/dhcpd << EOF cat > /etc/sysconfig/dhcpd << EOF
DHCPDARGS="enp0s9" DHCPDARGS="enp0s8"
EOF EOF
echo "_________________Перезагрузка и старт dncpd________________________" echo "_________________Перезагрузка и старт dncpd________________________"
systemctl restart dhcpd systemctl restart dhcpd
systemctl start dhcpd systemctl enable dhcpd -now

49
dns
View file

@ -1,7 +1,26 @@
#!/bit/bash #!/bin/bash
read -p "Введите 1 чтобы использовать старыe IP или 2 чтобы использовать новые IP: " Z
if [[ $Z == 1 ]]; then
dns=192.168.3.2
hqr=172.16.4.2
brr=172.16.5.2
brs=192.168.2.2
hqc=192.168.4.2
doc=172.16.4.1
web=172.16.5.1
else
read -p "Введите Ip-адрес dns сервера: " dns
read -p "Введите Ip-адрес HQ-RTR: " hqr
read -p "Введите Ip-адрес BR-RTR: " brr
read -p "Введите Ip-адрес BR-SRV: " brs
read -p "Введите адрес HQ-CLI: " hqc
read -p "Введите адрес docer: " doc
read -p "Введите адрес web: " web
fi
cat > /etc/named.conf << EOF cat > /etc/named.conf << EOF
options { options {
listen-on port 53 { 127.0.0.1; 192.168.3.2; }; listen-on port 53 { 127.0.0.1; $dns; };
listen-on-v6 port 53 { none; }; listen-on-v6 port 53 { none; };
directory "/var/named"; directory "/var/named";
dump-file "/var/named/data/cache_dump.db"; dump-file "/var/named/data/cache_dump.db";
@ -11,7 +30,8 @@ options {
recursing-file "/var/named/data/named.recursing"; recursing-file "/var/named/data/named.recursing";
allow-query { any; }; allow-query { any; };
forward first; forward first;
forwarders { 8.8.8.8; }; forwarders { 8.8.8.8; 5.255.255.242; };
allow-transfer { $brs; };
}; };
logging { logging {
@ -43,10 +63,10 @@ type master;
file "master/4.168.192.in-addr.arpa"; file "master/4.168.192.in-addr.arpa";
}; };
#zone "4.16.172.in-addr.arpa" { zone "4.16.172.in-addr.arpa" {
#type master; type master;
#file "4.16.172.in-addr.arpa"; file "master/4.16.172.in-addr.arpa";
#}; };
EOF EOF
@ -68,13 +88,13 @@ au-team.irpo. IN SOA ns01.au-team.irpo. root.au-team.irpo. (
IN NS hq-cli.au-team.irpo. IN NS hq-cli.au-team.irpo.
IN NS docker.au-team.irpo. IN NS docker.au-team.irpo.
IN NS web.au-team.irpo. IN NS web.au-team.irpo.
br-srv IN A 192.168.2.2 br-srv IN A $brs
hq-rtr IN A 172.16.4.2 hq-rtr IN A $hqr
br-rtr IN A 172.16.5.2 br-rtr IN A $brr
hq-srv IN A 192.168.3.2 hq-srv IN A $dns
hq-cli IN A 192.168.4.2 hq-cli IN A $hqc
docker IN A 172.16.4.1 docker IN A $doc
web IN A 172.16.5.1 web IN A $web
EOF EOF
# Zone for HQ-SRV # Zone for HQ-SRV
@ -123,6 +143,7 @@ read -p "Resolution?: " res
if [[ -n $res ]]; then if [[ -n $res ]]; then
chown -R root:named /var/named/master chown -R root:named /var/named/master
chmod 0640 /var/named/master/* chmod 0640 /var/named/master/*
echo Resolution completed
fi fi
echo "" echo ""
echo "_______________________Перезагрузка named______________________" echo "_______________________Перезагрузка named______________________"

29
int
View file

@ -10,8 +10,9 @@ while a==1
echo "2. Калькулятор маски" echo "2. Калькулятор маски"
echo "3. IP-адрес" echo "3. IP-адрес"
echo "4. Forward и masquerade" echo "4. Forward и masquerade"
echo "5. Перезагрузить машину" echo "5. VLAN"
echo "6. Time zone" echo "6. Перезагрузить машину"
echo "7. Time zone"
echo "0. Выход" echo "0. Выход"
echo "" echo ""
read num read num
@ -44,7 +45,7 @@ timestamp=$(date +%s)
[ipv4] [ipv4]
address1=$ip_s3 address1=$ip_s3
dns=8.8.8.8 dns=192.168.3.2; 8.8.8.8;
gateway=$gt_s3 gateway=$gt_s3
method=manual method=manual
@ -72,14 +73,12 @@ EOF
systemctl restart NetworkManager systemctl restart NetworkManager
fi fi
echo "" echo ""
echo "___________________________Enp0s10___________________________" echo "___________________________Enp0s10_____________________________"
read -p "Введите ip-адрес или пропустите: " ip_s10 read -p "Введите ip-адрес или пропустите: " ip_s10
if [[ -n $ip_s10 ]]; then if [[ -n $ip_s10 ]]; then
nmcli connection modify enp0s10 ipv4.method manual ipv4.addresses $ip_s10 ipv6.method disabled nmcli connection modify enp0s10 ipv4.method manual ipv4.addresses $ip_s10 ipv6.method disabled
systemctl restart NetworkManager systemctl restart NetworkManager
fi fi
systemctl restart NetworkManager
elif (( $num == 4 )); then elif (( $num == 4 )); then
echo "" echo ""
echo "_____________________________Forward и Masquerade__________________________" echo "_____________________________Forward и Masquerade__________________________"
@ -88,7 +87,7 @@ EOF
iptables -F iptables -F
read -p "Введите количество ip-адресов для которых необходимо задать Masquerade: " a read -p "Введите количество ip-адресов для которых необходимо задать Masquerade: " a
if (( $a == 2 )); then if (( $a == 2 )); then
if [[ -n $ip_s8 || $ip_s9 ]]; then if [[ -n $ip_s8 && $ip_s9 ]]; then
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
iptables -t nat -A POSTROUTING -s $ip_s9 -o enp0s3 -j MASQUERADE iptables -t nat -A POSTROUTING -s $ip_s9 -o enp0s3 -j MASQUERADE
echo "Готово" echo "Готово"
@ -110,7 +109,7 @@ EOF
iptables-save --file /etc/sysconfig/iptables iptables-save --file /etc/sysconfig/iptables
elif (( $num == 5)); then elif (( $num == 6)); then
read -p "Перезвгрузить?: " r read -p "Перезвгрузить?: " r
if (( $r == n || $r == N)); then if (( $r == n || $r == N)); then
echo "No" echo "No"
@ -118,6 +117,16 @@ EOF
reboot reboot
fi fi
elif (( $num == 5)); then
echo ""
echo "___________________________VLAN__________________________________"
read -p "Введите имя интерфеса vlan: " Name
read -p "Введите родительский интерфейс: " vpa
read -p "Введите тэг vlan: " id
read -p "Введите ip-адрес: " ip
nmcli connection add type vlan con-name $Name ifname $Name dev $vpa id $id ipv4.addresses $ip
systemctl restart NetworkManager
elif (( $num == 2)); then elif (( $num == 2)); then
echo "" echo ""
echo "____________________________Калькулятор____________________________" echo "____________________________Калькулятор____________________________"
@ -127,9 +136,9 @@ EOF
echo $mask echo $mask
echo"" echo""
elif (( $num == 6)); then elif (( $num == 7)); then
echo "For watch time zone inter: timedatectl list-timezones" echo "For watch time zone inter: timedatectl list-timezones"
echo "Inter timedatectl set-timezone 'timezone' " echo "Inter timedatectl set-timezone Asia/Yekaterinburg "
chmod 600 /etc/sudoers chmod 600 /etc/sudoers
fi fi

View file

@ -2,7 +2,7 @@
read -p "Введите id роутера(1.1.1.1): " r_id read -p "Введите id роутера(1.1.1.1): " r_id
read -p "Введите подсеть для enp0s3 (172.16.5.0/28): " ip_s3 read -p "Введите подсеть для enp0s3 (172.16.5.0/28): " ip_s3
read -p "Введите подсеть для enp0s8(192.168.2.0/26): " ip_s8 read -p "Введите подсеть для enp0s8(192.168.2.0/27): " ip_s8
read -p "Введите подсеть для туннеля(192.168.9.0/30): " ip_tun read -p "Введите подсеть для туннеля(192.168.9.0/30): " ip_tun
read -p "Введите имя(BR-RTR): " name read -p "Введите имя(BR-RTR): " name
read -p "Imput name for tunnel(gre1): " tun read -p "Imput name for tunnel(gre1): " tun
@ -45,7 +45,7 @@ router ospf
network $ip_tun area 0 network $ip_tun area 0
exit exit
! !
interface $tun interface gre1
ip ospf network point-to-point ip ospf network point-to-point
ip ospf authentication message-digest ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1 ip ospf message-digest-key 1 md5 1

View file

@ -45,7 +45,7 @@ router ospf
network $ip_tun area 0 network $ip_tun area 0
exit exit
! !
interface $tun interface gre1
ip ospf network point-to-point ip ospf network point-to-point
ip ospf authentication message-digest ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1 ip ospf message-digest-key 1 md5 1

28
usr
View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# Задание 3, Модуль 1 (HQ-SRV / BR-SRV) # Задание 3, Модуль 1 (HQ-SRV / BR-SRV)
read -p "Введите логин: " L
read -p "Введите пароль: " P
[ $EUID -ne 0 ] && echo "Требуется root" && exit 1 [ $EUID -ne 0 ] && echo "Требуется root" && exit 1
@ -7,11 +9,31 @@
useradd -m remote_user 2>/dev/null useradd -m remote_user 2>/dev/null
# 2. Пользователь sshuser (UID 2026, пароль P@ssw0rd) # 2. Пользователь sshuser (UID 2026, пароль P@ssw0rd)
useradd -u 2026 -m sshuser 2>/dev/null useradd -u 2026 -m $L 2>/dev/null
echo "sshuser:user" | chpasswd echo "$L:$P" | chpasswd
# 3. Sudo без пароля для sshuser # 3. Sudo без пароля для sshuser
echo "sshuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers echo "$L ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
chmod 440 /etc/sudoers chmod 440 /etc/sudoers
cat > /etc/ssh/sshd_config << EOF
Port 2026
AllowUsers $L
MaxAuthTries 2
EOF
cat > /etc/selinux/config << EOF
SELINUX=disabled
SELINUX=targeted
EOF
touch /etc/ssh/ban
echo "Authorized access only" > /etc/ssh/ban
echo "Banner /etc/ssh/ban" >> /etc/ssh/sshd_config
systemctl restart sshd
echo "Готово" echo "Готово"
echo ""
echo "Имя: $L"
echo "Пароль: $P"