|
| 1 | +# prefixd Lab Environment |
| 2 | + |
| 3 | +Containerlab topologies for testing FlowSpec with real Juniper routers. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. Install containerlab: |
| 8 | + ```bash |
| 9 | + bash -c "$(curl -sL https://get.containerlab.dev)" |
| 10 | + ``` |
| 11 | + |
| 12 | +2. Download router images from Juniper (free account required): |
| 13 | + - **vJunos-router**: https://support.juniper.net/support/downloads/?p=vjunos-router |
| 14 | + - **cJunosEvolved**: https://support.juniper.net/support/downloads/?p=cjunosevolved |
| 15 | + |
| 16 | +3. Import images into containerlab: |
| 17 | + ```bash |
| 18 | + # vJunos-router (MX-based) |
| 19 | + cd /path/to/downloaded/images |
| 20 | + containerlab tools vrnetlab import vjunos-router-23.2R1.15.qcow2 |
| 21 | + |
| 22 | + # cJunosEvolved (PTX-based) |
| 23 | + containerlab tools vrnetlab import cjunosevolved-24.2R1.17.qcow2 |
| 24 | + ``` |
| 25 | + |
| 26 | +## Topologies |
| 27 | + |
| 28 | +### vjunos-flowspec.clab.yml |
| 29 | +Tests FlowSpec with vJunos-router (MX-based Junos). This matches most production deployments. |
| 30 | + |
| 31 | +``` |
| 32 | +┌─────────────┐ eBGP ┌─────────────┐ |
| 33 | +│ GoBGP │◄─────────────►│ vJunos │ |
| 34 | +│ (prefixd) │ FlowSpec │ Router │ |
| 35 | +└─────────────┘ └─────────────┘ |
| 36 | + AS 65001 AS 65002 |
| 37 | +``` |
| 38 | + |
| 39 | +### cjunos-flowspec.clab.yml |
| 40 | +Tests FlowSpec with cJunosEvolved (PTX-based Junos Evolved). Future-proof testing. |
| 41 | + |
| 42 | +``` |
| 43 | +┌─────────────┐ eBGP ┌─────────────┐ |
| 44 | +│ GoBGP │◄─────────────►│ cJunos │ |
| 45 | +│ (prefixd) │ FlowSpec │ Evolved │ |
| 46 | +└─────────────┘ └─────────────┘ |
| 47 | + AS 65001 AS 65002 |
| 48 | +``` |
| 49 | + |
| 50 | +## Quick Start |
| 51 | + |
| 52 | +```bash |
| 53 | +# Start vJunos lab |
| 54 | +cd /path/to/prefixd/lab |
| 55 | +sudo containerlab deploy -t vjunos-flowspec.clab.yml |
| 56 | + |
| 57 | +# Wait for router to boot (~5-10 min for vJunos, ~15 min for cJunos) |
| 58 | +sudo containerlab inspect -t vjunos-flowspec.clab.yml |
| 59 | + |
| 60 | +# SSH to router (default: admin/admin@123) |
| 61 | +ssh admin@clab-vjunos-flowspec-router |
| 62 | + |
| 63 | +# Verify BGP session |
| 64 | +show bgp summary |
| 65 | + |
| 66 | +# Check FlowSpec rules |
| 67 | +show route table inetflow.0 |
| 68 | +show firewall filter __flowspec_default_inet__ |
| 69 | +``` |
| 70 | + |
| 71 | +## Testing FlowSpec |
| 72 | + |
| 73 | +1. Start prefixd connected to the lab GoBGP: |
| 74 | + ```bash |
| 75 | + # Update configs/prefixd.yaml to point to lab GoBGP |
| 76 | + # bgp.gobgp_grpc: "172.20.20.2:50051" |
| 77 | + cargo run -- --config ./configs |
| 78 | + ``` |
| 79 | + |
| 80 | +2. Inject a test event: |
| 81 | + ```bash |
| 82 | + curl -X POST http://localhost:8080/v1/events \ |
| 83 | + -H "Content-Type: application/json" \ |
| 84 | + -d '{ |
| 85 | + "timestamp": "2026-01-18T00:00:00Z", |
| 86 | + "source": "lab_test", |
| 87 | + "victim_ip": "203.0.113.10", |
| 88 | + "vector": "udp_flood", |
| 89 | + "bps": 1000000000, |
| 90 | + "pps": 1000000, |
| 91 | + "top_dst_ports": [53], |
| 92 | + "confidence": 0.9 |
| 93 | + }' |
| 94 | + ``` |
| 95 | + |
| 96 | +3. Verify on router: |
| 97 | + ```bash |
| 98 | + # Check FlowSpec route received |
| 99 | + show route table inetflow.0 |
| 100 | + |
| 101 | + # Check firewall filter created |
| 102 | + show firewall filter __flowspec_default_inet__ |
| 103 | + |
| 104 | + # Check filter counters |
| 105 | + show firewall filter __flowspec_default_inet__ detail |
| 106 | + ``` |
| 107 | + |
| 108 | +## Cleanup |
| 109 | + |
| 110 | +```bash |
| 111 | +sudo containerlab destroy -t vjunos-flowspec.clab.yml |
| 112 | +``` |
| 113 | + |
| 114 | +## Resource Requirements |
| 115 | + |
| 116 | +| Router | RAM | CPU | Boot Time | |
| 117 | +|--------|-----|-----|-----------| |
| 118 | +| vJunos-router | 5 GB | 4 cores | ~5-10 min | |
| 119 | +| cJunosEvolved | 8 GB | 4 cores | ~15 min | |
| 120 | + |
| 121 | +## Troubleshooting |
| 122 | + |
| 123 | +### Router not accepting FlowSpec |
| 124 | +Check import policy: |
| 125 | +``` |
| 126 | +show configuration policy-options policy-statement FLOWSPEC-IMPORT |
| 127 | +show configuration protocols bgp group GOBGP import |
| 128 | +``` |
| 129 | + |
| 130 | +### BGP session not establishing |
| 131 | +Check reachability and config: |
| 132 | +``` |
| 133 | +ping 172.20.20.2 |
| 134 | +show bgp neighbor 172.20.20.2 |
| 135 | +show configuration protocols bgp |
| 136 | +``` |
| 137 | + |
| 138 | +### FlowSpec rules not installing |
| 139 | +Check validation: |
| 140 | +``` |
| 141 | +show route receive-protocol bgp 172.20.20.2 table inetflow.0 detail |
| 142 | +show route validation-state inetflow.0 |
| 143 | +``` |
0 commit comments