-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (124 loc) · 4.9 KB
/
Makefile
File metadata and controls
147 lines (124 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.PHONY: help setup auth up down restart logs status bird birdc tailscale shell-bird shell-tailscale ris-visibility
# Default target
help:
@echo "PeerLab - Available Commands"
@echo "============================"
@echo ""
@echo "Setup:"
@echo " make setup - Start Tailscale container (first step)"
@echo " make auth - Authenticate with Headscale (second step)"
@echo " make up - Start full stack after authentication (third step)"
@echo ""
@echo "Container Management:"
@echo " make down - Stop and remove all containers"
@echo " make restart - Restart all containers"
@echo " make logs - Show logs from all containers"
@echo " make status - Show container status"
@echo ""
@echo "BIRD Commands:"
@echo " make bird - Run any BIRD command (usage: make bird CMD='show protocols')"
@echo " make bird-status - Show BIRD status"
@echo " make bird-protocols - Show BGP protocols"
@echo " make bird-routes - Show all received routes"
@echo " make bird-routes-count - Count received routes"
@echo " make bird-exports - Show routes being advertised"
@echo " make bird-prefixes - Show user-configured prefixes"
@echo " make bird-config - Reload BIRD configuration"
@echo " make shell-bird - Open shell in BIRD container"
@echo ""
@echo "Monitoring:"
@echo " make ris-visibility - Check prefix visibility on RIPE RIS route collectors"
@echo ""
@echo "Tailscale Commands:"
@echo " make tailscale - Run any Tailscale command (usage: make tailscale CMD='status')"
@echo " make ts-status - Show Tailscale connection status"
@echo " make ts-ip - Show Tailscale IP address"
@echo " make ts-ping - Ping ixpfra01 via Tailscale"
@echo " make shell-tailscale - Open shell in Tailscale container"
@echo ""
@echo "Examples:"
@echo " make bird CMD='show route protocol ixpfra01'"
@echo " make tailscale CMD='ping 100.64.0.2'"
# Setup workflow
setup:
@echo "Starting Tailscale container..."
@docker-compose up -d tailscale
@echo ""
@echo "✅ Tailscale container started"
@echo ""
@echo "Next step: Authenticate with Headscale"
@echo "Run: make auth"
auth:
@echo "Starting Headscale authentication..."
@echo ""
@docker exec -it peerlab-tailscale tailscale up --login-server=https://headscale.nxthdr.dev --accept-routes --reset
@echo ""
@echo "✅ Authentication complete"
@echo ""
@echo "Next step: Start the full stack"
@echo "Run: make up"
# Container management
up:
@echo "Starting PeerLab..."
@docker-compose up -d
@echo ""
@echo "✅ PeerLab is starting up"
@echo ""
@echo "Check status with: make status"
down:
docker-compose down
restart:
docker-compose restart
logs:
docker-compose logs -f
status:
@echo "=== Container Status ==="
@docker-compose ps
@echo ""
@echo "=== Tailscale Status ==="
@docker exec peerlab-tailscale tailscale status 2>/dev/null || echo "Tailscale not ready. Run 'make setup' then 'make auth'"
@echo ""
@echo "=== BIRD Protocols ==="
@docker exec peerlab-bird birdc show protocols 2>/dev/null || echo "BIRD not ready. Run 'make up' after authentication"
# BIRD commands
bird:
@docker exec -ti peerlab-bird birdc $(CMD)
bird-status:
@docker exec peerlab-bird birdc show status
bird-protocols:
@docker exec peerlab-bird birdc show protocols
bird-routes:
@docker exec peerlab-bird birdc show route
bird-routes-count:
@docker exec peerlab-bird birdc show route count
bird-exports:
@echo "=== Routes Being Advertised to IXP Peers ==="
@docker exec peerlab-bird sh -c 'for proto in $$(birdc show protocols | grep "^ixp" | awk "{print \$$1}"); do echo ""; echo "→ $$proto:"; result=$$(birdc "show route export $$proto" 2>/dev/null | grep -v "^BIRD" | grep -v "^Table"); if [ -n "$$result" ]; then echo "$$result"; else echo " (no routes - session may not be established)"; fi; done'
bird-prefixes:
@echo "=== User-Configured Prefixes ==="
@docker exec peerlab-bird birdc show route protocol user_prefixes 2>/dev/null || echo "No user prefixes configured"
bird-config:
@docker exec peerlab-bird birdc configure
shell-bird:
@docker exec -ti peerlab-bird /bin/bash
# Tailscale commands
tailscale:
@docker exec -ti peerlab-tailscale tailscale $(CMD)
ts-status:
@docker exec peerlab-tailscale tailscale status
ts-ip:
@docker exec peerlab-tailscale tailscale ip -4
ts-ping:
@docker exec peerlab-tailscale ping -c 4 100.64.0.2
shell-tailscale:
@docker exec -ti peerlab-tailscale /bin/sh
# Monitoring
ris-visibility:
@echo "=== RIPE RIS Visibility ==="
@docker exec peerlab-bird birdc show route protocol user_prefixes 2>/dev/null \
| grep -oE '[0-9a-f:]+/[0-9]+' \
| while read prefix; do \
count=$$(curl -s "https://stat.ripe.net/data/looking-glass/data.json?resource=$$prefix" \
| python3 -c "import sys,json; print(len(json.load(sys.stdin).get('data',{}).get('rrcs',[])))"); \
echo "$$prefix: $$count RIS route collectors"; \
done