Paul Jakma | 3a02d1f | 2007-11-01 14:29:11 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Public domain, not copyrighted.. |
| 4 | |
| 5 | NUM=5 |
| 6 | VTYBASE=2610 |
| 7 | ASBASE=64560 |
| 8 | BGPD=/path/to/bgpd |
| 9 | PREFIX=192.168.145 |
| 10 | |
| 11 | for H in `seq 1 ${NUM}` ; do |
| 12 | CONF=/etc/quagga/bgpd${H}.conf |
| 13 | ADDR=${PREFIX}.${H} |
| 14 | |
| 15 | if [ ! -e "$CONF" ] ; then |
| 16 | # This sets up a ring of bgpd peerings |
| 17 | NEXT=$(( ($H % ${NUM}) + 1 )) |
| 18 | PREV=$(( (($H + 3) % ${NUM}) + 1 )) |
| 19 | NEXTADDR="${PREFIX}.${NEXT}" |
| 20 | NEXTAS=$((${ASBASE} + $NEXT)) |
| 21 | PREVADDR="${PREFIX}.${PREV}" |
| 22 | PREVAS=$((${ASBASE} + $PREV)) |
| 23 | |
| 24 | # Edit config to suit. |
| 25 | cat > "$CONF" <<- EOF |
| 26 | password whatever |
| 27 | service advanced-vty |
| 28 | ! |
| 29 | router bgp $((64560+${H})) |
| 30 | bgp router-id ${ADDR} |
| 31 | network 10.${H}.1.0/24 pathlimit 1 |
| 32 | network 10.${H}.2.0/24 pathlimit 2 |
| 33 | network 10.${H}.3.0/24 pathlimit 3 |
| 34 | neighbor default peer-group |
| 35 | neighbor default update-source ${ADDR} |
| 36 | neighbor default capability orf prefix-list both |
| 37 | neighbor default soft-reconfiguration inbound |
| 38 | neighbor ${NEXTADDR} remote-as ${NEXTAS} |
| 39 | neighbor ${NEXTADDR} peer-group default |
| 40 | neighbor ${PREVADDR} remote-as ${PREVAS} |
| 41 | neighbor ${PREVADDR} peer-group default |
| 42 | EOF |
| 43 | chown quagga:quagga "$CONF" |
| 44 | fi |
| 45 | # You may want to automatically add configure a local address |
| 46 | # on a loop interface. |
| 47 | # |
| 48 | # Solaris: ifconfig vni${H} plumb ${ADDR}/32 up |
| 49 | # Linux: ip address add ${ADDR}/32 dev lo 2> /dev/null |
| 50 | ${BGPD} -i /var/run/quagga/bgpd${H}.pid \ |
| 51 | -l ${ADDR} \ |
| 52 | -f /etc/quagga/bgpd${H}.conf \ |
| 53 | -P $((${VTYBASE}+${H})) \ |
| 54 | -d |
| 55 | done |