You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.1 KiB

#!/usr/bin/bash
configFrr() {
echo "Configure Frr zebra."
case $1 in
r1) INTERFACES="eth1 eth2"; NETS="1 2 3"; ID=1 ;;
r2) INTERFACES="eth0 eth1 eth2"; NETS="2 4 5"; ID=2;;
r3) INTERFACES="eth1 eth2"; NETS="4 6 7"; ID=3;;
r4) INTERFACES="eth0 eth1"; NETS="3 8"; ID=4;;
r5) INTERFACES="eth0 eth1 eth2"; NETS="5 7 8"; ID=5;;
esac
vdn-ssh root@$1 "
#sed -i -re 's/^(zebra|ospfd)=.*$/\1=yes/g' /etc/quagga/daemons
#set -x
[ ! -e /etc/quaga/vtysh.conf ] && cp /usr/share/doc/quagga-core/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
cat << EOF > /etc/quagga/zebra.conf
!/etc/quagga/zebra.conf
hostname router-zebra
password zebra*
log file /var/log/quagga/zebra.log
EOF
cat << EOF > /etc/quagga/ospfd.conf
!/etc/quagga/ospfd.conf
hostname router-ospfd
password ospfd*
log file /var/log/quagga/ospfd.log
EOF
for i in $INTERFACES; do
cat << EOF >> /etc/quagga/ospfd.conf
interface \$i
ip ospf hello-interval 5
ip ospf dead-interval 20
EOF
done
cat << EOF >> /etc/quagga/ospfd.conf
router ospf
ospf router-id 1.1.1.$ID
EOF
for i in $NETS; do
echo network 192.168.\$i.0/24 area 0 >> /etc/quagga/ospfd.conf
done
#cp /usr/share/doc/quagga/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
#chown quagga:quagga /etc/quagga/zebra.conf /etc/quagga/ospfd.conf
#chown :quaggavty /etc/quagga/vtysh.conf
systemctl enable zebra
systemctl restart zebra
systemctl enable ospfd
systemctl restart ospfd
"
}
configQuagga() {
echo "Configure Quagga Zebra."
case $1 in
r1) INTERFACES="eth1 eth2"; NETS="1 2 3"; ID=1 ;;
r2) INTERFACES="eth0 eth1 eth2"; NETS="2 4 5"; ID=2;;
r3) INTERFACES="eth1 eth2"; NETS="4 6 7"; ID=3;;
r4) INTERFACES="eth0 eth1"; NETS="3 8"; ID=4;;
r5) INTERFACES="eth0 eth1 eth2"; NETS="5 7 8"; ID=5;;
esac
vdn-ssh root@$1 "
#sed -i -re 's/^(zebra|ospfd)=.*$/\1=yes/g' /etc/quagga/daemons
#set -x
[ ! -e /etc/quaga/vtysh.conf ] && cp /usr/share/doc/quagga-core/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
cat << EOF > /etc/quagga/zebra.conf
!/etc/quagga/zebra.conf
hostname router-zebra
password zebra*
log file /var/log/quagga/zebra.log
EOF
cat << EOF > /etc/quagga/ospfd.conf
!/etc/quagga/ospfd.conf
hostname router-ospfd
password ospfd*
log file /var/log/quagga/ospfd.log
EOF
for i in $INTERFACES; do
cat << EOF >> /etc/quagga/ospfd.conf
interface \$i
ip ospf hello-interval 5
ip ospf dead-interval 20
EOF
done
cat << EOF >> /etc/quagga/ospfd.conf
router ospf
ospf router-id 1.1.1.$ID
EOF
for i in $NETS; do
echo network 192.168.\$i.0/24 area 0 >> /etc/quagga/ospfd.conf
done
#cp /usr/share/doc/quagga/examples/vtysh.conf.sample /etc/quagga/vtysh.conf
#chown quagga:quagga /etc/quagga/zebra.conf /etc/quagga/ospfd.conf
#chown :quaggavty /etc/quagga/vtysh.conf
systemctl enable zebra
systemctl restart zebra
systemctl enable ospfd
systemctl restart ospfd
"
}
configBase() {
setErrorHandler
echoStart
#setIpv6WorkAround $1
setHostname $1
}
endConfig() {
unsetErrorHandler
echoDone
}