blob: 001e91c6acbd49e5d5ac16f651806187fe311f62 [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 Jakmace9c3cc2008-06-12 18:53:09 +000012CHOWNSTR=quagga:quagga
Paul Jakma3a02d1f2007-11-01 14:29:11 +000013
14for H in `seq 1 ${NUM}` ; do
Paul Jakma0e7c1242008-06-01 14:26:48 +000015 CONF="${CONFBASE}"/bgpd${H}.conf
Paul Jakma3a02d1f2007-11-01 14:29:11 +000016 ADDR=${PREFIX}.${H}
17
18 if [ ! -e "$CONF" ] ; then
19 # This sets up a ring of bgpd peerings
20 NEXT=$(( ($H % ${NUM}) + 1 ))
21 PREV=$(( (($H + 3) % ${NUM}) + 1 ))
22 NEXTADDR="${PREFIX}.${NEXT}"
23 NEXTAS=$((${ASBASE} + $NEXT))
24 PREVADDR="${PREFIX}.${PREV}"
25 PREVAS=$((${ASBASE} + $PREV))
26
27 # Edit config to suit.
28 cat > "$CONF" <<- EOF
29 password whatever
30 service advanced-vty
31 !
32 router bgp $((64560+${H}))
33 bgp router-id ${ADDR}
34 network 10.${H}.1.0/24 pathlimit 1
35 network 10.${H}.2.0/24 pathlimit 2
36 network 10.${H}.3.0/24 pathlimit 3
37 neighbor default peer-group
38 neighbor default update-source ${ADDR}
39 neighbor default capability orf prefix-list both
40 neighbor default soft-reconfiguration inbound
41 neighbor ${NEXTADDR} remote-as ${NEXTAS}
42 neighbor ${NEXTADDR} peer-group default
43 neighbor ${PREVADDR} remote-as ${PREVAS}
44 neighbor ${PREVADDR} peer-group default
Paul Jakmace9c3cc2008-06-12 18:53:09 +000045 !
46 address-family ipv6
47 network fffe:${H}::/48
48 network fffe:${H}:1::/48 pathlimit 1
49 network fffe:${H}:2::/48 pathlimit 3
50 network fffe:${H}:3::/48 pathlimit 3
51 neighbor default activate
52 neighbor default capability orf prefix-list both
53 neighbor default default-originate
54 neighbor ${NEXTADDR} peer-group default
55 neighbor ${PREVADDR} peer-group default
56 exit-address-family
57 !
58 line vty
59 !
60 end
Paul Jakma3a02d1f2007-11-01 14:29:11 +000061 EOF
Paul Jakmace9c3cc2008-06-12 18:53:09 +000062 chown ${CHOWNSTR} "$CONF"
Paul Jakma3a02d1f2007-11-01 14:29:11 +000063 fi
64 # You may want to automatically add configure a local address
65 # on a loop interface.
66 #
67 # Solaris: ifconfig vni${H} plumb ${ADDR}/32 up
68 # Linux: ip address add ${ADDR}/32 dev lo 2> /dev/null
Paul Jakma0e7c1242008-06-01 14:26:48 +000069 ${BGPD} -i "${PIDBASE}"/bgpd${H}.pid \
Paul Jakma3a02d1f2007-11-01 14:29:11 +000070 -l ${ADDR} \
Paul Jakma0e7c1242008-06-01 14:26:48 +000071 -f "${CONF}" \
Paul Jakma3a02d1f2007-11-01 14:29:11 +000072 -P $((${VTYBASE}+${H})) \
73 -d
74done