dfdf
This commit is contained in:
parent
0f2ed271cb
commit
380b10c9dd
18
adm
Executable file
18
adm
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Задание 3, Модуль 1 (HQ-RTR / BR-RTR)
|
||||||
|
|
||||||
|
[ $EUID -ne 0 ] && echo "Требуется root" && exit 1
|
||||||
|
|
||||||
|
# Пользователь net_admin (маршрутизаторы)
|
||||||
|
USER="net_admin"
|
||||||
|
PASS="admin"
|
||||||
|
|
||||||
|
# Создание пользователя
|
||||||
|
useradd -m -s /bin/bash "$USER" 2>/dev/null
|
||||||
|
echo "$USER:$PASS" | chpasswd
|
||||||
|
|
||||||
|
# Sudo без пароля
|
||||||
|
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
|
||||||
|
chmod 440 /etc/sudoers
|
||||||
|
|
||||||
|
echo "Готово"
|
||||||
31
dhcp
Executable file
31
dhcp
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/nash
|
||||||
|
|
||||||
|
cat > /etc/dhcp/dhcpd.conf << EOF
|
||||||
|
default-lease-time 600;
|
||||||
|
max-lease-time 7200;
|
||||||
|
authoritative;
|
||||||
|
|
||||||
|
subnet 192.168.4.0 netmask 255.255.255.248 {
|
||||||
|
range 192.168.4.2 192.168.4.6;
|
||||||
|
option domain-name-servers 192.168.3.2, 8.8.4.4;
|
||||||
|
option subnet-mask 255.255.255.248;
|
||||||
|
option routers 172.16.4.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
host hq-cli {
|
||||||
|
hardware ethernet
|
||||||
|
08:00:27:c7:82:fa;
|
||||||
|
fixed-address
|
||||||
|
192.168.4.2;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chmod 600 /etc/dhcp/dhcpd.conf
|
||||||
|
|
||||||
|
cat > /etc/sysconfig/dhcpd << EOF
|
||||||
|
DHCPDARGS="enp0s9"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "_________________Перезагрузка и старт dncpd________________________"
|
||||||
|
systemctl restart dhcpd
|
||||||
|
systemctl start dhcpd
|
||||||
123
dns
Executable file
123
dns
Executable file
|
|
@ -0,0 +1,123 @@
|
||||||
|
#!/bit/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; };
|
||||||
|
};
|
||||||
|
|
||||||
|
zone "." IN {
|
||||||
|
type hint;
|
||||||
|
file "var/named/named.ca";
|
||||||
|
};
|
||||||
|
|
||||||
|
include "/etc/named.rfcq912.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 "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
74
hqs
Executable 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
|
||||||
|
|
||||||
71
ospf_brr
Executable file
71
ospf_brr
Executable file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!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
|
||||||
|
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 gre1
|
||||||
|
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
|
||||||
80
ospf_hqr
Executable file
80
ospf_hqr
Executable file
|
|
@ -0,0 +1,80 @@
|
||||||
|
#!bin/bash
|
||||||
|
|
||||||
|
read -p "Введите имя(HQ-RTR): " name
|
||||||
|
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 gre1
|
||||||
|
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
|
||||||
14
tunel
Executable file
14
tunel
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
read -p "Введите локальный ip-адрес для тунеля(172.16.0.2): " l_ip
|
||||||
|
read -p "Введите удаленный ip-адрес для туннеля(172.16.0.2): " r_ip
|
||||||
|
read -p "Введите ip-адрес туннеля(192.168.9.1/30)" t_ip
|
||||||
|
read -p "Введите имя туннеля(gre1): " name
|
||||||
|
|
||||||
|
ip link delete gre1 2>/dev/null
|
||||||
|
|
||||||
|
ip tunnel add $name mode gre local $l_ip remote $r_ip ttl 64 dev enp0s3
|
||||||
|
ip addr add $t_ip dev $name
|
||||||
|
ip link set $name up
|
||||||
|
|
||||||
|
echo "Введите nmcli connection modify "$name" ip-tunnel.ttl 64"
|
||||||
|
systemctl restart NetworkManager
|
||||||
17
usr
Executable file
17
usr
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Задание 3, Модуль 1 (HQ-SRV / BR-SRV)
|
||||||
|
|
||||||
|
[ $EUID -ne 0 ] && echo "Требуется root" && exit 1
|
||||||
|
|
||||||
|
# 1. Пользователь remote_user
|
||||||
|
useradd -m remote_user 2>/dev/null
|
||||||
|
|
||||||
|
# 2. Пользователь sshuser (UID 2026, пароль P@ssw0rd)
|
||||||
|
useradd -u 2026 -m sshuser 2>/dev/null
|
||||||
|
echo "sshuser:user" | chpasswd
|
||||||
|
|
||||||
|
# 3. Sudo без пароля для sshuser
|
||||||
|
echo "sshuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
|
||||||
|
chmod 440 /etc/sudoers
|
||||||
|
|
||||||
|
echo "Готово"
|
||||||
Loading…
Reference in a new issue