VyOSXXXIV · Route RedistributionConnected redistribution
Redistributing connected routes — physical interface routes, when to include, when to exclude
What you'll learn
- Configure `redistribute connected` with a route-map under the BGP address family on VyOS 1.5 LTS
- Decide which connected routes to advertise and which to exclude
- Distinguish `redistribute connected` from a `network` statement
- Explain why an iBGP mesh takes its loopbacks from the IGP rather than from BGP
- Diagnose a route leak caused by `redistribute connected` without a filter
Prerequisites
Verified against VyOS 1.5.x LTS (circinus) · VyOS 1.4.x (sagitta) — legacy · FRRouting 10.x (VyOS 1.5) · Linux kernel 6.6 LTS (VyOS 1.5 base) · strongSwan 5.9.x (IPsec) · WireGuard 1.0.x (kernel module + userspace tooling)
redistribute connected carries the router’s connected routes — the
subnets assigned to its interfaces — into the BGP table. It differs
from a network statement in one important way: a connected route
exists only while its interface is up, so the advertisement follows
the interface. That is the property that makes it the right tool, and
the property that makes an unfiltered one dangerous.
On VyOS 1.5 LTS the production use cases are narrow:
- Customer point-to-point links — a /30 between the router and the customer. Redistributing it makes the link reachable, and withdraws it when the link drops.
- DMZ or service subnets — the router hosts a service on a /28 that other networks need to reach.
- Loopbacks in a BGP-only underlay — a data-centre fabric with no IGP, where each router’s loopback has to reach the other end somehow, and BGP is the only protocol running.
The production anti-pattern is an unfiltered redistribute connected, which advertises every interface subnet the router has:
the transit link to the upstream, the management interface, the
peering subnet, and whatever gets configured next week.
Connected versus a network statement
Two mechanisms advertise a local prefix into BGP, and the difference between them is what happens when reality changes:
networkenumerates a prefix explicitly. It is advertised as long as a matching route exists in the routing table, and it does not care which interface produced that route.set protocols bgp address-family ipv4-unicast network 10.10.0.0/16advertises the aggregate whether it came from a static route, an IGP, or an interface.redistribute connectedadvertises interface subnets and follows their state. An interface that goes down takes its prefix out of BGP with it.
For a customer /30, the redistribution is right: the link state is
exactly the signal you want BGP to carry. For a summary you always
want advertised, the network statement is right, because it says
what you mean and does not change when somebody renumbers an
interface.
Both statements live under the address family on VyOS 1.5, which is the placement that moved in 1.4 and the first thing a 1.3-era runbook gets wrong here.
flowchart TB
LO["lo\n10.0.0.1/32"]
ETH0["eth0\n192.168.1.1/24 (customer)"]
ETH1["eth1\n10.10.10.1/30 (transit to upstream)"]
ETH2["eth2\n172.16.0.1/24 (management)"]
PEER["eth3\n198.51.100.1/29 (eBGP peering)"]
R["Connected routes in the RIB"]
RM["route-map CONNECTED-TO-BGP"]
BGPLoc["BGP table"]
X["Not redistributed"]
LO --> R
ETH0 --> R
ETH1 --> R
ETH2 --> R
PEER --> R
R --> RM
RM -->|"customer 192.168.1.0/24"| BGPLoc
RM -->|"transit, management, peering, loopback"| X
The configuration
configure
set policy prefix-list CONNECTED-TO-BGP rule 10 action 'permit'
set policy prefix-list CONNECTED-TO-BGP rule 10 description 'customer LAN'
set policy prefix-list CONNECTED-TO-BGP rule 10 prefix '192.168.1.0/24'
set policy prefix-list CONNECTED-TO-BGP rule 20 action 'permit'
set policy prefix-list CONNECTED-TO-BGP rule 20 description 'customer point-to-point'
set policy prefix-list CONNECTED-TO-BGP rule 20 prefix '203.0.113.4/30'
set policy route-map CONNECTED-TO-BGP rule 10 action 'permit'
set policy route-map CONNECTED-TO-BGP rule 10 match ip address prefix-list 'CONNECTED-TO-BGP'
set policy route-map CONNECTED-TO-BGP rule 10 set metric '100'
set policy route-map CONNECTED-TO-BGP rule 10 set community add '64512:500'
set protocols bgp system-as 64512
set protocols bgp address-family ipv4-unicast redistribute connected route-map 'CONNECTED-TO-BGP'
commit
save
The prefix-list enumerates what may pass. The route-map matches it and stamps a metric and a community so that downstream policy has something to filter on. The redistribution statement names the route-map.
The connected-source semantics
A connected route is live only while its interface is up. Take the interface down and the route leaves the RIB; the redistribution follows and BGP withdraws the prefix.
That is useful. A customer /30 that goes down is withdrawn without anybody doing anything, and downstream peers converge on an alternative if one exists.
It is also the mechanism behind the leak. redistribute connected
is a standing instruction, not a snapshot. The moment any new
interface is configured — a management VLAN, a temporary link for a
migration, a new peering — its subnet becomes a connected route and
is caught by the standing instruction. If the route-map does not
exclude it, it is advertised, and nobody typed a command to make
that happen.
Which interfaces belong in BGP
| Interface type | Include? | Reason |
|---|---|---|
| Customer point-to-point (/30 or /31) | Yes | The link should be reachable, and its state is worth signalling |
| Customer LAN | Yes | The customer’s subnet is the thing you are being paid to carry |
| DMZ or service subnet | Usually | If external networks need to reach the service |
| Loopback, with an IGP running | No | The IGP already carries it, and it is what BGP next-hops resolve against |
| Loopback, BGP-only underlay | Yes | Nothing else can carry it |
| Transit link to an upstream | No | Infrastructure addressing; advertising it invites traffic you did not sell |
| Peering subnet | No | Same, and it hands a mapper your topology |
| Management interface | No | Management should not be reachable from the routing table you advertise |
| Interface in a customer VRF | Depends | Yes within that customer’s VRF, no in the global table |
The defensive idiom is one line long: enumerate every subnet that should be advertised, and let the implicit deny handle the rest.
The loopback question
The table above splits on whether an IGP is running, and that split is worth its own section because it is where the strongest habits collide.
In a network with OSPF or IS-IS, router loopbacks belong to the IGP,
not to BGP. The iBGP mesh peers with update-source set to the
loopback, and every BGP next-hop has to resolve against something —
which is the IGP. Redistributing a loopback into iBGP on top of that
adds nothing, and in the wrong order it does not work at all:
A BGP-only underlay is the genuine exception. In a fabric with no
IGP, redistribute connected filtered to the loopbacks is how each
switch’s loopback becomes reachable — and it works there because the
sessions are eBGP over the point-to-point links, so the next-hop is
the neighbour’s link address rather than the prefix being advertised.
The circularity above does not arise.
Operational commands
show ip route connected
show interfaces
show ip bgp
show ip bgp 192.168.1.0/24
show bgp ipv4 neighbors 203.0.113.5 advertised-routes
vtysh -c 'show route-map CONNECTED-TO-BGP'
vtysh -c 'show ip prefix-list CONNECTED-TO-BGP 192.168.1.0/24'
show bgp ipv4 neighbors <peer> advertised-routes is the validation
that matters. Everything else tells you what the router intends;
this tells you what the peer is being given. Run it after every
redistribution change and read the list, not its length.
vtysh -c 'show ip prefix-list <name> <prefix>' answers “would this
prefix pass” directly, which is faster than reasoning about rule
order. And show route-map carries a hit count per rule: a rule with
zero hits and a policy that is not working is a match problem, not a
set problem.
Failure modes
Unfiltered redistribution leaks management and peering subnets
redistribute connected was committed without a route-map. Every
interface subnet is in BGP, including 172.16.0.0/24 (management)
and the peering subnet.
Diagnostic:
show bgp ipv4 neighbors <peer> advertised-routeslists subnets nobody intended to sell.- The upstream’s received-routes shows the same, which is how you usually find out.
Fix: add the prefix-list and route-map, attach the route-map to the redistribution, and ask the upstream to confirm the withdrawal propagated. Withdrawing a leaked prefix is fast; getting it out of other people’s route caches and filters is not, so treat this as an incident rather than a tidy-up.
The interface is up and the prefix is not in BGP
Work down the chain rather than guessing:
show ip route connected— is the connected route in the RIB at all? An interface with an address but no carrier has no connected route.vtysh -c 'show ip prefix-list CONNECTED-TO-BGP 192.168.1.0/24'— does the prefix-list permit it?- Check
geandleon the prefix-list rule. A rule withprefix 192.168.0.0/16and noge/lematches only the exact /16, not the /24 inside it. This is the single most common reason a prefix-list “does not work”. vtysh -c 'show route-map CONNECTED-TO-BGP'— is rule 10 taking hits?
The route is in the BGP table and not in the FIB
The next-hop is unresolvable. On an iBGP-received route this is
usually the loopback circularity above, or a border router that
should be setting next-hop-self and is not.
Diagnostic: show ip bgp 192.168.1.0/24 names the next-hop, and
show ip route for that next-hop address says whether the router can
reach it. If the answer is no, the fix is in the IGP or in
next-hop-self, not in the redistribution.
Rollback
comparebeforecommit, and confirm the redistribution and its route-map are both in the diff. Committing the redistribution without the route-map — because the route-map was going to be a second commit — is a leak with your name on it.commit-confirm 5for the change, since redistribution changes what the upstream receives immediately.- To remove the redistribution:
delete protocols bgp address-family ipv4-unicast redistribute connectedandcommit. - To remove only the filter and keep the redistribution:
delete protocols bgp address-family ipv4-unicast redistribute connected route-map. Understand what this does before typing it — it does not disable anything, it makes the redistribution unfiltered. rollback Nexists but currently requires a reboot to take effect. For a leak you want the targeteddeleteand a commit, not a reboot.
Production discipline
Cross-course references
II-VyOS-RoutingFund(vyos-ii-03-connected-routes) covers the connected route source.XXXIV-VyOS-Redistribution(vyos-xxxiv-05-redist-kernel) covers the kernel route source, which carries the same filtering discipline.XXX-VyOS-BGPRouteReflectorscovers the iBGP mesh whose loopback reachability this lesson argues belongs in the IGP.
Quiz
Knowledge check · 4 questions
Q1. In a BGP-only data-centre underlay with no IGP running, which connected subnet is the canonical thing to redistribute into BGP?
Q2. A `network` statement and `redistribute connected` are equivalent ways to advertise a prefix from a router into BGP.
Q3. R1 has lo (10.0.0.1/32), eth0 (192.168.1.1/24, customer), eth1 (172.16.0.1/24, management) and eth2 (198.51.100.1/29, eBGP peering). `redistribute connected` was committed with no route-map and the upstream is receiving all four subnets. Only the customer LAN should be advertised. What is the fix?
R1 runs `set protocols bgp address-family ipv4-unicast redistribute connected` with no route-map. `show bgp ipv4 neighbors 198.51.100.2 advertised-routes` lists 10.0.0.1/32, 192.168.1.0/24, 172.16.0.0/24 and 198.51.100.0/29. The upstream has confirmed it is accepting all four. An IGP carries the loopbacks internally.
Q4. R1 redistributes its loopback 10.0.0.1/32 into iBGP. R2 shows the route in `show ip bgp` but not in `show ip route`, and cannot reach 10.0.0.1. Why, and what is the correct fix?
R1 and R2 are iBGP peers in AS 64512. R1 has 10.0.0.1/32 on lo and redistributes connected into BGP. On R2, `show ip bgp 10.0.0.1/32` shows the path with a next-hop of 10.0.0.1 and marks it inaccessible. `show ip route 10.0.0.1` on R2 returns nothing. No IGP is carrying the loopbacks; the iBGP session is established over the directly connected link addresses.
Passing score: 75%. Answers are checked in this browser.