diff --git a/README.md b/README.md index f921718..778d090 100644 --- a/README.md +++ b/README.md @@ -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 -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 push -uf origin main ``` ## 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 diff --git a/adm b/adm index 6579db7..34b9885 100755 --- a/adm +++ b/adm @@ -1,18 +1,18 @@ #!/bin/bash # Задание 3, Модуль 1 (HQ-RTR / BR-RTR) - +read -p "Введите логин: " L +read -p "Введите пароль: " P [ $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 +useradd -m -s /bin/bash "$L" 2>/dev/null +echo "$L:$P" | chpasswd # Sudo без пароля -echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers +echo "$L ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers chmod 440 /etc/sudoers echo "Готово" +echo "" +echo "Имя: $L" +echo "Пароль: $P" diff --git a/dhcp b/dhcp index ee43dcc..12d22d1 100755 --- a/dhcp +++ b/dhcp @@ -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 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; +subnet $Q netmask $E { + range $S $K; + option domain-name-servers $R, $B; + option subnet-mask $E; + option routers $T; } @@ -17,15 +86,15 @@ host hq-cli { hardware ethernet 08:00:27:c7:82:fa; fixed-address -192.168.4.2; +$S; } EOF chmod 600 /etc/dhcp/dhcpd.conf cat > /etc/sysconfig/dhcpd << EOF -DHCPDARGS="enp0s9" +DHCPDARGS="enp0s8" EOF echo "_________________Перезагрузка и старт dncpd________________________" systemctl restart dhcpd -systemctl start dhcpd +systemctl enable dhcpd -now diff --git a/dns b/dns index 6747ba9..da21ce6 100755 --- a/dns +++ b/dns @@ -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 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; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; @@ -11,7 +30,8 @@ options { recursing-file "/var/named/data/named.recursing"; allow-query { any; }; forward first; - forwarders { 8.8.8.8; }; + forwarders { 8.8.8.8; 5.255.255.242; }; + allow-transfer { $brs; }; }; logging { @@ -43,10 +63,10 @@ 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"; -#}; +zone "4.16.172.in-addr.arpa" { +type master; +file "master/4.16.172.in-addr.arpa"; +}; 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 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 +br-srv IN A $brs +hq-rtr IN A $hqr +br-rtr IN A $brr +hq-srv IN A $dns +hq-cli IN A $hqc +docker IN A $doc +web IN A $web EOF # Zone for HQ-SRV @@ -123,6 +143,7 @@ read -p "Resolution?: " res if [[ -n $res ]]; then chown -R root:named /var/named/master chmod 0640 /var/named/master/* + echo Resolution completed fi echo "" echo "_______________________Перезагрузка named______________________" diff --git a/int b/int index 74aaef1..6dc5e08 100755 --- a/int +++ b/int @@ -10,8 +10,9 @@ while a==1 echo "2. Калькулятор маски" echo "3. IP-адрес" echo "4. Forward и masquerade" - echo "5. Перезагрузить машину" - echo "6. Time zone" + echo "5. VLAN" + echo "6. Перезагрузить машину" + echo "7. Time zone" echo "0. Выход" echo "" read num @@ -44,7 +45,7 @@ timestamp=$(date +%s) [ipv4] address1=$ip_s3 -dns=8.8.8.8 +dns=192.168.3.2; 8.8.8.8; gateway=$gt_s3 method=manual @@ -72,14 +73,12 @@ EOF systemctl restart NetworkManager fi echo "" - echo "___________________________Enp0s10___________________________" + echo "___________________________Enp0s10_____________________________" read -p "Введите ip-адрес или пропустите: " ip_s10 if [[ -n $ip_s10 ]]; then nmcli connection modify enp0s10 ipv4.method manual ipv4.addresses $ip_s10 ipv6.method disabled systemctl restart NetworkManager fi - systemctl restart NetworkManager - elif (( $num == 4 )); then echo "" echo "_____________________________Forward и Masquerade__________________________" @@ -88,7 +87,7 @@ EOF iptables -F read -p "Введите количество ip-адресов для которых необходимо задать Masquerade: " a 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_s9 -o enp0s3 -j MASQUERADE echo "Готово" @@ -110,7 +109,7 @@ EOF iptables-save --file /etc/sysconfig/iptables - elif (( $num == 5)); then + elif (( $num == 6)); then read -p "Перезвгрузить?: " r if (( $r == n || $r == N)); then echo "No" @@ -118,6 +117,16 @@ EOF reboot 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 echo "" echo "____________________________Калькулятор____________________________" @@ -127,9 +136,9 @@ EOF echo $mask echo"" - elif (( $num == 6)); then + elif (( $num == 7)); then 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 fi diff --git a/ospf_brr b/ospf_brr index c4f80e2..a899a53 100755 --- a/ospf_brr +++ b/ospf_brr @@ -2,7 +2,7 @@ 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 "Введите подсеть для enp0s8(192.168.2.0/27): " ip_s8 read -p "Введите подсеть для туннеля(192.168.9.0/30): " ip_tun read -p "Введите имя(BR-RTR): " name read -p "Imput name for tunnel(gre1): " tun @@ -45,7 +45,7 @@ router ospf network $ip_tun area 0 exit ! -interface $tun +interface gre1 ip ospf network point-to-point ip ospf authentication message-digest ip ospf message-digest-key 1 md5 1 diff --git a/ospf_hqr b/ospf_hqr index d53f2f8..cc97b74 100755 --- a/ospf_hqr +++ b/ospf_hqr @@ -45,7 +45,7 @@ router ospf network $ip_tun area 0 exit ! -interface $tun +interface gre1 ip ospf network point-to-point ip ospf authentication message-digest ip ospf message-digest-key 1 md5 1 diff --git a/usr b/usr index e959374..c47008f 100755 --- a/usr +++ b/usr @@ -1,5 +1,7 @@ #!/bin/bash # Задание 3, Модуль 1 (HQ-SRV / BR-SRV) +read -p "Введите логин: " L +read -p "Введите пароль: " P [ $EUID -ne 0 ] && echo "Требуется root" && exit 1 @@ -7,11 +9,31 @@ 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 +useradd -u 2026 -m $L 2>/dev/null +echo "$L:$P" | chpasswd # 3. Sudo без пароля для sshuser -echo "sshuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers +echo "$L ALL=(ALL) NOPASSWD: ALL" > /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 "Имя: $L" +echo "Пароль: $P"