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