build: Add QuaggaId to README.NetBSD
[jleu-quagga.git] / tools / multiple-bgpd.sh
blob028ad696e52a1189e064150b2a798b09dd8622eb
1 #!/bin/bash
3 # Public domain, not copyrighted..
5 NUM=5
6 VTYBASE=2610
7 ASBASE=64560
8 BGPD=/path/to/bgpd
9 PREFIX=192.168.145.
10 #PREFIX=3ffe:123:456::
11 ADDRPLEN=32
12 CONFBASE=/tmp
13 PIDBASE=/var/run/quagga
14 CHOWNSTR=quagga:quagga
16 for H in `seq 1 ${NUM}` ; do
17 CONF="${CONFBASE}"/bgpd${H}.conf
18 ADDR=${PREFIX}${H}
20 if [ ! -e "$CONF" ] ; then
21 # This sets up a ring of bgpd peerings
22 NEXT=$(( ($H % ${NUM}) + 1 ))
23 PREV=$(( (($H + 3) % ${NUM}) + 1 ))
24 NEXTADDR="${PREFIX}${NEXT}"
25 NEXTAS=$((${ASBASE} + $NEXT))
26 PREVADDR="${PREFIX}${PREV}"
27 PREVAS=$((${ASBASE} + $PREV))
29 # Edit config to suit.
30 cat > "$CONF" <<- EOF
31 password whatever
32 service advanced-vty
34 router bgp $((64560+${H}))
35 bgp router-id ${ADDR}
36 network 10.${H}.1.0/24 pathlimit 1
37 network 10.${H}.2.0/24 pathlimit 2
38 network 10.${H}.3.0/24 pathlimit 3
39 neighbor default peer-group
40 neighbor default update-source ${ADDR}
41 neighbor default capability orf prefix-list both
42 neighbor default soft-reconfiguration inbound
43 neighbor ${NEXTADDR} remote-as ${NEXTAS}
44 neighbor ${NEXTADDR} peer-group default
45 neighbor ${PREVADDR} remote-as ${PREVAS}
46 neighbor ${PREVADDR} peer-group default
48 address-family ipv6
49 network 3ffe:${H}::/48
50 network 3ffe:${H}:1::/48 pathlimit 1
51 network 3ffe:${H}:2::/48 pathlimit 3
52 network 3ffe:${H}:3::/48 pathlimit 3
53 neighbor default activate
54 neighbor default capability orf prefix-list both
55 neighbor default default-originate
56 neighbor ${NEXTADDR} peer-group default
57 neighbor ${PREVADDR} peer-group default
58 exit-address-family
60 line vty
62 end
63 EOF
64 chown ${CHOWNSTR} "$CONF"
66 # You may want to automatically add configure a local address
67 # on a loop interface.
69 # Solaris: ifconfig vni${H} plumb ${ADDR}/${ADDRPLEN} up
70 # Linux: ip address add ${ADDR}/${ADDRPLEN} dev lo 2> /dev/null
71 ${BGPD} -i "${PIDBASE}"/bgpd${H}.pid \
72 -l ${ADDR} \
73 -f "${CONF}" \
74 -P $((${VTYBASE}+${H})) \
76 done