﻿#!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 $tun
 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
