This commit is contained in:
root 2026-03-31 08:35:08 +03:00
parent e0a759d56b
commit fb28bd9d54
9 changed files with 412 additions and 44 deletions

7
adm Normal file → Executable file
View file

@ -5,7 +5,7 @@
# Пользователь net_admin (маршрутизаторы) # Пользователь net_admin (маршрутизаторы)
USER="net_admin" USER="net_admin"
PASS="password" PASS="admin"
# Создание пользователя # Создание пользователя
useradd -m -s /bin/bash "$USER" 2>/dev/null useradd -m -s /bin/bash "$USER" 2>/dev/null
@ -15,4 +15,7 @@ echo "$USER:$PASS" | chpasswd
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
chmod 440 /etc/sudoers chmod 440 /etc/sudoers
echo "Готово" echo "Готово"
echo ""
echo "Имя: $USER"
echo "Пароль: $PASS"

17
dhcp
View file

@ -1,4 +1,4 @@
#!/bin/nash #!/bin/bash
cat > /etc/dhcp/dhcpd.conf << EOF cat > /etc/dhcp/dhcpd.conf << EOF
default-lease-time 600; default-lease-time 600;
@ -7,10 +7,18 @@ authoritative;
subnet 192.168.4.0 netmask 255.255.255.248 { subnet 192.168.4.0 netmask 255.255.255.248 {
range 192.168.4.2 192.168.4.6; range 192.168.4.2 192.168.4.6;
option domain-name-servers 8.8.8.8, 8.8.4.4; option domain-name-servers 192.168.3.2, 8.8.4.4;
option subnet-mask 255.255.255.248; option subnet-mask 255.255.255.248;
option routers 192.168.4.1; option routers 192.168.4.1;
} }
host hq-cli {
hardware ethernet
08:00:27:c7:82:fa;
fixed-address
192.168.4.2;
}
EOF EOF
chmod 600 /etc/dhcp/dhcpd.conf chmod 600 /etc/dhcp/dhcpd.conf
@ -18,5 +26,6 @@ cat > /etc/sysconfig/dhcpd << EOF
DHCPDARGS="enp0s9" DHCPDARGS="enp0s9"
EOF EOF
systemctl enable dhcp echo "_________________Перезагрузка и старт dncpd________________________"
systemctl start dhcp systemctl restart dhcpd
systemctl start dhcpd

129
dns Executable file
View file

@ -0,0 +1,129 @@
#!/bin/bash
cat > /etc/named.conf << EOF
options {
listen-on port 53 { 127.0.0.1; 192.168.3.2; };
listen-on-v6 port 53 { none; };
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";
secroots-file "/var/named/data.named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { any; };
forward first;
forwarders { 8.8.8.8; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
zone "au-team.irpo" {
type master;
file "master/au-team.irpo";
};
zone "3.168.192.in-addr.arpa" {
type master;
file "master/3.168.192.in-addr.arpa";
};
zone "4.168.192.in-addr.arpa" {
type master;
file "master/4.168.192.in-addr.arpa";
};
zone "4.16.172.in-addr.arpa" {
type master;
file "master/4.16.172.in-addr.arpa";
};
EOF
mkdir /var/named/master
cat > /var/named/master/au-team.irpo << EOF
\$TTL 604800 ;
au-team.irpo. IN SOA ns01.au-team.irpo. root.au-team.irpo. (
1 ; Serial
600 ; Refresh
3600 ; Retry
1w ; Expire
360 ; Minimum TTL
)
IN NS br-srv.au-team.irpo.
IN NS hq-rtr.au-team.irpo.
IN NS br-rtr.au-team.irpo.
IN NS hq-srv.au-team.irpo.
IN NS hq-cli.au-team.irpo.
IN NS docker.au-team.irpo.
IN NS web.au-team.irpo.
br-srv IN A 192.168.2.2
hq-rtr IN A 172.16.4.2
br-rtr IN A 172.16.5.2
hq-srv IN A 192.168.3.2
hq-cli IN A 192.168.4.2
docker IN A 172.16.4.1
web IN A 172.16.5.1
EOF
# Zone for HQ-SRV
cat > /var/named/master/3.168.192.in-addr.arpa << EOF
\$TTL 604800 ;
@ IN SOA ns01.au-team.irpo. root.au-team.irpo. (
20060204 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ; Minimum
)
@ IN NS au-team.irpo.
2 IN PTR hq-srv.au-team.irpo.
EOF
# Zone for HQ-CLI
cat > /var/named/master/4.168.192.in-addr.arpa << EOF
\$TTL 604800 ;
@ IN SOA ns01.au-team.irpo. root.au-team.irpo. (
20060204 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ; Minimum
)
@ IN NS au-team.irpo.
2 IN PTR hq-cli.au-team.irpo.
EOF
# Zone for HQ-RTR
cat > /var/named/master/4.16.172.in-addr.arpa << EOF
\$TTL 604800 ;
@ IN SOA ns01.au-team.irpo. root.au-team.irpo.(
20060204 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ; Minimum
)
@ IN NS au-team.irpo.
2 IN PTR hq-rtr.au-team.irpo.
EOF
read -p "Resolution?: " res
if [[ -n $res ]]; then
chown -R root:named /var/named/master
chmod 0640 /var/named/master/*
fi
echo ""
echo "_______________________Перезагрузка named______________________"
systemctl restart named

74
hqs Executable file
View file

@ -0,0 +1,74 @@
#!/bin/bash
echo "hostname"
read -p "enter name" name
if [[ -n $name ]]; then
hostnamectl set-hostname $name
exec bash
fi
echo "enter enp0s3"
read enp0s3
if [[ -n $enp0s3 ]]; then
read -p "enter gateway" gat
read -p "enter dns" dns
cat > /etc/NetworkManager/system-connections/enp0s3.nmconnection << EOF
[connnection]
id=enp0s3
uuid=$(uuidgen)
tipe=ethernet
autoconnect-priority=-999
interface-name=enp0s3
timestamp=$(date +%s)
[ethernet]
[ipv4]
address1=$enp0s3
dns=$dns
gateway=$gat
method=manual
[ipv6]
addr-gen-mode=eui64
method=disabled
[proxy]
EOF
chmod 600 /etc/NetworkManager/system-connections/enp0s3.nmconnection
fi
read -p "Reboot?" o
if [[ -n $o ]]; then
reboot
fi
echo "enter accaunt"
read -p "continue: " can
if [[ -n $can ]]; then
useradd -u 2026 remote_user
passwd remote_user
cat >> /etc/sudoers << EOF
remote_user ALL=(ALL)NOPASSWD:ALL
EOF
fi
read -p "ftp?: " ftp
read -p "enter ip: " ip
if [[ -n $ftp ]]; then
iptables -I INPUT -p tcp --match multiport --dports 21,22,20000:25000 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp -d $ip --dport 21 -j MASQUERADE
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 21 -j DNAT --to-destination $ip:21
service iptables save
cat >> /etc/vsftpd/vsftpd.conf << EOF
pasv_min_port=20000
pasv_max_port=25000
pasv_enable=YES
EOF
chmod 600 /etc/vsftpd/vsftpd.conf
fi

61
int
View file

@ -4,15 +4,15 @@ a=1
while a==1 while a==1
do do
echo "" echo ""
echo "Enter number" echo "Выберите параметр"
echo "" echo ""
echo "1. Hostname" echo "1. Имя"
echo "2. Calculate the mask" echo "2. Калькулятор маски"
echo "3. IP" echo "3. IP-адрес"
echo "4. Forward and masquerade" echo "4. Forward и masquerade"
echo "5. Reboot" echo "5. Перезагрузить машину"
echo "6. Account" echo "6. Time zone"
echo "0. Exit" echo "0. Выход"
echo "" echo ""
read num read num
echo "" echo ""
@ -22,15 +22,15 @@ while a==1
break break
elif (( $num == 1 )); then elif (( $num == 1 )); then
echo "______________________Hostname_____________________" echo "______________________Имя_____________________"
read -p "Enter name(isp.au-team.irpo): " name read -p "Введите имя(isp.au-team.irpo): " name
hostnamectl set-hostname $name hostnamectl set-hostname $name
exec bash exec bash
elif (( $num == 3)); then elif (( $num == 3)); then
echo "_____________________Enp0s3_______________________" echo "_____________________Enp0s3_______________________"
read -p "Enter ip or skip for DHCP: " ip_s3 read -p "Введите ip-адрес или пропустите для DHCP: " ip_s3
if [[ -n $ip_s3 ]]; then if [[ -n $ip_s3 ]]; then
read -p "Enter gateway: " gt_s3 read -p "Введите шлюз или пропустите: " gt_s3
cat > /etc/NetworkManager/system-connections/enp0s3.nmconnection << EOF cat > /etc/NetworkManager/system-connections/enp0s3.nmconnection << EOF
[connection] [connection]
id=enp0s3 id=enp0s3
@ -59,21 +59,21 @@ EOF
fi fi
echo "" echo ""
echo "________________________Enp0s8_________________________" echo "________________________Enp0s8_________________________"
read -p "Enter ip or skip: " ip_s8 read -p "Введите ip-адрес или пропустите: " ip_s8
if [[ -n $ip_s8 ]]; then if [[ -n $ip_s8 ]]; then
nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses $ip_s8 ipv6.method disabled nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses $ip_s8 ipv6.method disabled
systemctl restart NetworkManager systemctl restart NetworkManager
fi fi
echo "" echo ""
echo "____________________________Enp0s9____________________________" echo "____________________________Enp0s9____________________________"
read -p "Enter ip or skip: " ip_s9 read -p "Введите ip-адрес или пропустите: " ip_s9
if [[ -n $ip_s9 ]]; then if [[ -n $ip_s9 ]]; then
nmcli connection modify enp0s9 ipv4.method manual ipv4.addresses $ip_s9 ipv6.method disabled nmcli connection modify enp0s9 ipv4.method manual ipv4.addresses $ip_s9 ipv6.method disabled
systemctl restart NetworkManager systemctl restart NetworkManager
fi fi
echo "" echo ""
echo "___________________________Enp0s10___________________________" echo "___________________________Enp0s10___________________________"
read -p "Enter ip or skip: " 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
@ -82,26 +82,28 @@ EOF
elif (( $num == 4 )); then elif (( $num == 4 )); then
echo "" echo ""
echo "_____________________________Forward and Masquerade__________________________" echo "_____________________________Forward и Masquerade__________________________"
sysctl net.ipv4.ip_forward=1 >> /etc/sysctl.conf sysctl net.ipv4.ip_forward=1 >> /etc/sysctl.conf
systemctl enable --now iptables systemctl enable --now iptables
iptables -F iptables -F
read -p "Enter ip for 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 "Готово"
else else
read -p "Enter ip for enp0s8(192.168.0.0/30): " ip_s8 read -p "Введите ip-адрес для enp0s8(192.168.0.0/30): " ip_s8
read -p "Enter ip for enp0s9(192.168.0.0/30): " ip_s9 read -p "Введите ip-адрес для enp0s9(192.168.0.0/30): " ip_s9
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
fi fi
elif (( $a == 1)); then elif (( $a == 1)); then
if [[ -n $ip_s8 ]]; then if [[ -n $ip_s8 ]]; 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
echo "Готово"
else else
read -p "Enter ip for enp0s8: " ip_s8 read -p "Введите ip для enp0s8: " ip_s8
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
fi fi
fi fi
@ -109,31 +111,26 @@ EOF
elif (( $num == 5)); then elif (( $num == 5)); then
read -p "Reboot?: " r read -p "Перезвгрузить?: " r
if (( $r == n || $r == N)); then if (( $r == n || $r == N)); then
echo "123" echo "No"
else else
reboot reboot
fi fi
elif (( $num == 2)); then elif (( $num == 2)); then
echo "" echo ""
echo "____________________________Calc____________________________" echo "____________________________Калькулятор____________________________"
read -p "Enter amount PC: " mask read -p "Введите количество PC: " mask
mask=$(echo "sqrt($mask)" | bc) mask=$(echo "sqrt($mask)" | bc)
mask=$((32 - $mask)) mask=$((32 - $mask))
echo $mask echo $mask
echo"" echo""
elif (( $num == 6)); then elif (( $num == 6)); then
echo "________________________Account_________________________" echo "For watch time zone inter: timedatectl list-timezones"
read -p "Yes or no?: " acc echo "Inter timedatectl set-timezone 'timezone' "
if [[ -n $acc ]]; then
read -p "Enter name acc: " acc_n
cat >> /etc/sudoers << EOF
$acc_n ALL=(ALL)NOPASSWD:ALL
EOF
chmod 600 /etc/sudoers chmod 600 /etc/sudoers
fi
fi fi
done done

72
ospf_brr Executable file
View file

@ -0,0 +1,72 @@
#!bin/bash
read -p "Введите id роутера(1.1.1.1): " r_id
read -p "Введите подсеть для enp0s3 (172.16.5.0/28): " ip_s3
read -p "Введите подсеть для enp0s8(192.168.2.0/26): " ip_s8
read -p "Введите подсеть для туннеля(192.168.9.0/30): " ip_tun
read -p "Введите имя(BR-RTR): " name
read -p "Imput name for tunnel(gre1): " tun
cat > /etc/frr/daemons << EOF
bgpd=no
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
pim6d=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
pbrd=no
bfdd=no
fabricd=no
vrrpd=no
pathd=no
EOF
cat > /etc/frr/frr.conf << EOF
frr version 10.1.2
frr defaults traditional
hostname $name
no ipv6 forwarding
!
interface $tun
no ip ospf passive
exit
!
router ospf
ospf router-id $r_id
area 0 authentication message-digest
passive-interface default
network $ip_s3 area 0
network $ip_s8 area 0
network $ip_tun area 0
exit
!
interface gre1
ip ospf network point-to-point
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
interface enp0s8
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
line vty
!
EOF
chmod 600 /etc/frr/frr.conf
echo ""
echo "__________________________Начало и перезагузка frr_____________________________"
systemctl restart frr
systemctl enable frr
systemctl start frr
echo ""
echo "_______________________________Проверка_______________________________"
systemctl status frr
ip route show

81
ospf_hqr Executable file
View file

@ -0,0 +1,81 @@
#!bin/bash
read -p "Введите имя(HQ-RTR): " name
read -p "Input name for tunnel(gre1): " tun
read -p "Введите id роутера(2.2.2.2): " r_id
read -p "Введите подсеть для enp0s3(172.16.4.0/28): " ip_s3
read -p "Введите подсеть для enp0s8(192.168.3.0/26): " ip_s8
read -p "Введите подсеть туннеля(192.168.9.0/30): " ip_tun
cat > /etc/frr/daemons << EOF
bgpd=no
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
pim6d=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
pbrd=no
bfdd=no
fabricd=no
vrrpd=no
pathd=no
EOF
cat > /etc/frr/frr.conf << EOF
frr version 10.1.2
frr defaults traditional
hostname $name
no ipv6 forwarding
!
interface $tun
no ip ospf passive
exit
!
router ospf
ospf router-id $r_id
area 0 authentication message-digest
passive-interface default
network $ip_s3 area 0
network $ip_s8 area 0
network $ip_tun area 0
exit
!
interface gre1
ip ospf network point-to-point
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
interface enp0s8
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
interface enp0s9
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
interface enp0s10
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 1
!
line vty
!
EOF
chmod 600 /etc/frr/frr.conf
echo ""
echo "__________________________Старт и перезагрузка frr_____________________________"
systemctl restart frr
systemctl enable frr
systemctl start frr
echo ""
echo "_______________________________Проверка_______________________________"
systemctl status frr
ip route show

10
tunel
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
read -p "Enter local ip(172.16.0.2): " l_ip read -p "Введите локальный ip-адрес для тунеля(172.16.0.2): " l_ip
read -p "Enter remote ip(172.16.0.2): " r_ip read -p "Введите удаленный ip-адрес для туннеля(172.16.0.2): " r_ip
read -p "Enter tun ip(192.168.9.1/30)" t_ip read -p "Введите ip-адрес туннеля(192.168.9.1/30)" t_ip
read -p "Enter name tunnel: " name read -p "Введите имя туннеля(gre1): " name
ip link delete gre1 2>/dev/null ip link delete gre1 2>/dev/null
@ -10,5 +10,5 @@ ip tunnel add $name mode gre local $l_ip remote $r_ip ttl 64 dev enp0s3
ip addr add $t_ip dev $name ip addr add $t_ip dev $name
ip link set $name up ip link set $name up
echo "Enter nmcli connection modify gre1 ip-tunnel.ttl 64" echo "Введите nmcli connection modify "$name" ip-tunnel.ttl 64"
systemctl restart NetworkManager systemctl restart NetworkManager

5
usr
View file

@ -8,10 +8,13 @@ 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 sshuser 2>/dev/null
echo "sshuser:123" | chpasswd echo "sshuser:user" | chpasswd
# 3. Sudo без пароля для sshuser # 3. Sudo без пароля для sshuser
echo "sshuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers echo "sshuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
chmod 440 /etc/sudoers chmod 440 /etc/sudoers
echo "Готово" echo "Готово"
echo ""
echo "Имя: sshuser"
echo "Пароль: user"