PacketLab
BGP · Attributes and Path Selection

Accumulated IGP Metric (AIGP)

Carry comparable interior cost across cooperating ASes, instead of choosing an exit using only the cost visible inside one AS.

Six-router cost model

One operator controls AS 65123 with R1–R2–R3 and AS 65456 with R4–R5–R6. Each AS has its own OSPF domain and a full iBGP mesh over loopbacks. R2–R4 and R3–R5 are the external links. R1 and R6 originate their Loopback0 /32s.

Lab topologyIllustrative network
.1 / .2 · cost 10.5 / .6 · cost 30.9 / .10 · eBGP.13 / .14 · eBGP.17 / .18 · cost 20.21 / .22 · cost 10R1AS 65123R2AS 65123R3AS 65123R4AS 65456R5AS 65456R6AS 65456
Solid lines: physical links. Link labels use the last octet of 192.0.2.x; every link is a separate /30. AS labels identify the protocol relationship. Loopback0 is 10.255.0.N/32 for router RN. Exact interfaces and subnets are listed below.
LinkFirst endpointSecond endpoint
R1–R2R1 GigabitEthernet1: 192.0.2.1/30R2 GigabitEthernet1: 192.0.2.2/30
R1–R3R1 GigabitEthernet2: 192.0.2.5/30R3 GigabitEthernet1: 192.0.2.6/30
R2–R4R2 GigabitEthernet2: 192.0.2.9/30R4 GigabitEthernet1: 192.0.2.10/30
R3–R5R3 GigabitEthernet2: 192.0.2.13/30R5 GigabitEthernet1: 192.0.2.14/30
R4–R6R4 GigabitEthernet2: 192.0.2.17/30R6 GigabitEthernet1: 192.0.2.18/30
R5–R6R5 GigabitEthernet2: 192.0.2.21/30R6 GigabitEthernet2: 192.0.2.22/30
Complete baseline configurations

R1

hostname R1
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.1 255.255.255.255
exit
interface GigabitEthernet1
 ip ospf cost 10
 ip address 192.0.2.1 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip ospf cost 30
 ip address 192.0.2.5 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.1
 network 10.255.0.1 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.1 0.0.0.0 area 0
 network 192.0.2.5 0.0.0.0 area 0
exit
router bgp 65123
 bgp router-id 10.255.0.1
 no bgp default ipv4-unicast
 neighbor 10.255.0.2 remote-as 65123
 neighbor 10.255.0.2 update-source Loopback0
 neighbor 10.255.0.3 remote-as 65123
 neighbor 10.255.0.3 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 10.255.0.2 activate
  neighbor 10.255.0.3 activate
  network 10.255.0.1 mask 255.255.255.255
 exit-address-family
end

R2

hostname R2
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.2 255.255.255.255
exit
interface GigabitEthernet1
 ip ospf cost 10
 ip address 192.0.2.2 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip address 192.0.2.9 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.2
 network 10.255.0.2 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.2 0.0.0.0 area 0
exit
router bgp 65123
 bgp router-id 10.255.0.2
 no bgp default ipv4-unicast
 neighbor 192.0.2.10 remote-as 65456
 neighbor 10.255.0.1 remote-as 65123
 neighbor 10.255.0.1 update-source Loopback0
 neighbor 10.255.0.3 remote-as 65123
 neighbor 10.255.0.3 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 192.0.2.10 activate
  neighbor 10.255.0.1 activate
  neighbor 10.255.0.1 next-hop-self
  neighbor 10.255.0.3 activate
  neighbor 10.255.0.3 next-hop-self
 exit-address-family
end

R3

hostname R3
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.3 255.255.255.255
exit
interface GigabitEthernet1
 ip ospf cost 30
 ip address 192.0.2.6 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip address 192.0.2.13 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.3
 network 10.255.0.3 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.6 0.0.0.0 area 0
exit
router bgp 65123
 bgp router-id 10.255.0.3
 no bgp default ipv4-unicast
 neighbor 192.0.2.14 remote-as 65456
 neighbor 10.255.0.1 remote-as 65123
 neighbor 10.255.0.1 update-source Loopback0
 neighbor 10.255.0.2 remote-as 65123
 neighbor 10.255.0.2 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 192.0.2.14 activate
  neighbor 10.255.0.1 activate
  neighbor 10.255.0.1 next-hop-self
  neighbor 10.255.0.2 activate
  neighbor 10.255.0.2 next-hop-self
 exit-address-family
end

R4

hostname R4
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.4 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.10 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip ospf cost 20
 ip address 192.0.2.17 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.4
 network 10.255.0.4 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.17 0.0.0.0 area 0
exit
router bgp 65456
 bgp router-id 10.255.0.4
 no bgp default ipv4-unicast
 neighbor 192.0.2.9 remote-as 65123
 neighbor 10.255.0.5 remote-as 65456
 neighbor 10.255.0.5 update-source Loopback0
 neighbor 10.255.0.6 remote-as 65456
 neighbor 10.255.0.6 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 192.0.2.9 activate
  neighbor 10.255.0.5 activate
  neighbor 10.255.0.5 next-hop-self
  neighbor 10.255.0.6 activate
  neighbor 10.255.0.6 next-hop-self
 exit-address-family
end

R5

hostname R5
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.5 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.14 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip ospf cost 10
 ip address 192.0.2.21 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.5
 network 10.255.0.5 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.21 0.0.0.0 area 0
exit
router bgp 65456
 bgp router-id 10.255.0.5
 no bgp default ipv4-unicast
 neighbor 192.0.2.13 remote-as 65123
 neighbor 10.255.0.4 remote-as 65456
 neighbor 10.255.0.4 update-source Loopback0
 neighbor 10.255.0.6 remote-as 65456
 neighbor 10.255.0.6 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 192.0.2.13 activate
  neighbor 10.255.0.4 activate
  neighbor 10.255.0.4 next-hop-self
  neighbor 10.255.0.6 activate
  neighbor 10.255.0.6 next-hop-self
 exit-address-family
end

R6

hostname R6
ip cef
interface Loopback0
 ip ospf cost 10
 ip address 10.255.0.6 255.255.255.255
exit
interface GigabitEthernet1
 ip ospf cost 20
 ip address 192.0.2.18 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip ospf cost 10
 ip address 192.0.2.22 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.6
 network 10.255.0.6 0.0.0.0 area 0
 passive-interface Loopback0
 ip ospf cost 10
 network 192.0.2.18 0.0.0.0 area 0
 network 192.0.2.22 0.0.0.0 area 0
exit
router bgp 65456
 bgp router-id 10.255.0.6
 no bgp default ipv4-unicast
 neighbor 10.255.0.4 remote-as 65456
 neighbor 10.255.0.4 update-source Loopback0
 neighbor 10.255.0.5 remote-as 65456
 neighbor 10.255.0.5 update-source Loopback0
 address-family ipv4 unicast
  no auto-summary
  neighbor 10.255.0.4 activate
  neighbor 10.255.0.5 activate
  network 10.255.0.6 mask 255.255.255.255
 exit-address-family
end
Outputs are illustrative, not recorded router results. Each lesson is a separate lab. Allow updates to converge after changes; the selected baseline path is an example when all earlier criteria tie.

The diagram labels symmetric OSPF interface costs. Each Loopback0 has OSPF cost 10. The external links are not included in either OSPF domain; their route-to-adjacent-next-hop cost is zero in this comparison model. Use an image supporting AIGP and a consistent metric scale across the cooperating domains.

Default BGP in both directions

R1# show ip bgp 10.255.0.6/32
BGP routing table entry for 10.255.0.6/32
Paths: (2 available, best #1)
  65456
    10.255.0.2 (metric 20) from 10.255.0.2
      Origin IGP, metric 0, localpref 100, valid, internal, best
  65456
    10.255.0.3 (metric 40) from 10.255.0.3
      Origin IGP, metric 0, localpref 100, valid, internal

R6# show ip bgp 10.255.0.1/32
BGP routing table entry for 10.255.0.1/32
Paths: (2 available, best #2)
  65123
    10.255.0.4 (metric 30) from 10.255.0.4
      Origin IGP, metric 0, localpref 100, valid, internal
  65123
    10.255.0.5 (metric 20) from 10.255.0.5
      Origin IGP, metric 0, localpref 100, valid, internal, best

The parenthesized metric is local IGP cost to the BGP next hop; the separate metric 0 is MED. R1 chooses its nearer border R2, while R6 chooses its nearer border R5. Neither decision includes the other AS’s interior cost.

End-to-end forwarding directionUpper pathLower path
R1 to R610 + 20 + destination loopback 10 = 4030 + 10 + 10 = 50
R6 to R120 + 10 + 10 = 4010 + 30 + 10 = 50

Default R1 forwarding happens to select the lower total cost; default R6 forwarding does not.

Try MED hints

First try exporting each border’s OSPF cost to the local destination as a fixed MED. Configure the four separate border routers below; all paths compared across each boundary still come from the same neighboring AS.

Four border MED policies

R2

ip prefix-list TARGET seq 5 permit 10.255.0.1/32
route-map MED-HINT permit 10
 match ip address prefix-list TARGET
 set metric 20
exit
route-map MED-HINT permit 20
exit
router bgp 65123
 address-family ipv4 unicast
  neighbor 192.0.2.10 route-map MED-HINT out
 exit-address-family

R3

ip prefix-list TARGET seq 5 permit 10.255.0.1/32
route-map MED-HINT permit 10
 match ip address prefix-list TARGET
 set metric 40
exit
route-map MED-HINT permit 20
exit
router bgp 65123
 address-family ipv4 unicast
  neighbor 192.0.2.14 route-map MED-HINT out
 exit-address-family

R4

ip prefix-list TARGET seq 5 permit 10.255.0.6/32
route-map MED-HINT permit 10
 match ip address prefix-list TARGET
 set metric 30
exit
route-map MED-HINT permit 20
exit
router bgp 65456
 address-family ipv4 unicast
  neighbor 192.0.2.9 route-map MED-HINT out
 exit-address-family

R5

ip prefix-list TARGET seq 5 permit 10.255.0.6/32
route-map MED-HINT permit 10
 match ip address prefix-list TARGET
 set metric 20
exit
route-map MED-HINT permit 20
exit
router bgp 65456
 address-family ipv4 unicast
  neighbor 192.0.2.13 route-map MED-HINT out
 exit-address-family
R2# clear ip bgp 192.0.2.10 soft out
R3# clear ip bgp 192.0.2.14 soft out
R4# clear ip bgp 192.0.2.9 soft out
R5# clear ip bgp 192.0.2.13 soft out
R1# show ip bgp 10.255.0.6/32
BGP routing table entry for 10.255.0.6/32
Paths: (1 available, best #1)
  65456
    10.255.0.3 (metric 40) from 10.255.0.3
      Origin IGP, metric 20, localpref 100, valid, internal, best

R6# show ip bgp 10.255.0.1/32
BGP routing table entry for 10.255.0.1/32
Paths: (1 available, best #1)
  65123
    10.255.0.4 (metric 30) from 10.255.0.4
      Origin IGP, metric 20, localpref 100, valid, internal, best

After outbound policies are re-evaluated, R1 is pulled toward R3’s lower remote MED, even though its local approach is more costly. R6 now chooses R4. A border that prefers an internal alternative stops advertising its former external candidate internally, explaining the single paths shown. MED compares a hint; it does not add remote and local costs.

Enable and originate AIGP

Replace the MED experiment with AIGP. Explicitly enable AIGP for every session within this trusted domain, both internal and external, on both ends. Do not export it indiscriminately to Internet or customer peers.

Enable AIGP on all six routers

R1

router bgp 65123
 address-family ipv4 unicast
  neighbor 10.255.0.2 aigp
  neighbor 10.255.0.3 aigp
 exit-address-family

R2

router bgp 65123
 address-family ipv4 unicast
  neighbor 192.0.2.10 aigp
  neighbor 10.255.0.1 aigp
  neighbor 10.255.0.3 aigp
 exit-address-family

R3

router bgp 65123
 address-family ipv4 unicast
  neighbor 192.0.2.14 aigp
  neighbor 10.255.0.1 aigp
  neighbor 10.255.0.2 aigp
 exit-address-family

R4

router bgp 65456
 address-family ipv4 unicast
  neighbor 192.0.2.9 aigp
  neighbor 10.255.0.5 aigp
  neighbor 10.255.0.6 aigp
 exit-address-family

R5

router bgp 65456
 address-family ipv4 unicast
  neighbor 192.0.2.13 aigp
  neighbor 10.255.0.4 aigp
  neighbor 10.255.0.6 aigp
 exit-address-family

R6

router bgp 65456
 address-family ipv4 unicast
  neighbor 10.255.0.4 aigp
  neighbor 10.255.0.5 aigp
 exit-address-family

At each border, remove MED-HINT and seed only the local destination prefix’s AIGP from its installed OSPF route metric. That prefix resolves to an OSPF route on the border; the network origination remains on R1 or R6.

Replace the four MED policies with AIGP origin policies

R2

ip prefix-list TARGET seq 5 permit 10.255.0.1/32
route-map AIGP-SEED permit 10
 match ip address prefix-list TARGET
 set aigp-metric igp-metric
exit
route-map AIGP-SEED permit 20
exit
router bgp 65123
 address-family ipv4 unicast
  no neighbor 192.0.2.10 route-map MED-HINT out
  neighbor 192.0.2.10 route-map AIGP-SEED out
 exit-address-family

R3

ip prefix-list TARGET seq 5 permit 10.255.0.1/32
route-map AIGP-SEED permit 10
 match ip address prefix-list TARGET
 set aigp-metric igp-metric
exit
route-map AIGP-SEED permit 20
exit
router bgp 65123
 address-family ipv4 unicast
  no neighbor 192.0.2.14 route-map MED-HINT out
  neighbor 192.0.2.14 route-map AIGP-SEED out
 exit-address-family

R4

ip prefix-list TARGET seq 5 permit 10.255.0.6/32
route-map AIGP-SEED permit 10
 match ip address prefix-list TARGET
 set aigp-metric igp-metric
exit
route-map AIGP-SEED permit 20
exit
router bgp 65456
 address-family ipv4 unicast
  no neighbor 192.0.2.9 route-map MED-HINT out
  neighbor 192.0.2.9 route-map AIGP-SEED out
 exit-address-family

R5

ip prefix-list TARGET seq 5 permit 10.255.0.6/32
route-map AIGP-SEED permit 10
 match ip address prefix-list TARGET
 set aigp-metric igp-metric
exit
route-map AIGP-SEED permit 20
exit
router bgp 65456
 address-family ipv4 unicast
  no neighbor 192.0.2.13 route-map MED-HINT out
  neighbor 192.0.2.13 route-map AIGP-SEED out
 exit-address-family

Re-evaluate the changed outbound advertisements on each external session and wait for internal updates to converge. Existing next-hop-self settings are essential: when a router changes NEXT_HOP, AIGP accumulates the appropriate interior cost to the previous next hop rather than losing that segment.

R2# clear ip bgp 192.0.2.10 soft out
R3# clear ip bgp 192.0.2.14 soft out
R4# clear ip bgp 192.0.2.9 soft out
R5# clear ip bgp 192.0.2.13 soft out

R2# show ip bgp neighbors 192.0.2.10 | include AIGP
  AIGP is enabled

Verify accumulated cost

R1# show ip bgp 10.255.0.6/32
BGP routing table entry for 10.255.0.6/32
Paths: (2 available, best #1)
  65456
    10.255.0.2 (metric 20) from 10.255.0.2
      Origin IGP, aigp-metric 30, metric 0, localpref 100, valid, internal, best
  65456
    10.255.0.3 (metric 40) from 10.255.0.3
      Origin IGP, aigp-metric 20, metric 0, localpref 100, valid, internal

R6# show ip bgp 10.255.0.1/32
BGP routing table entry for 10.255.0.1/32
Paths: (2 available, best #1)
  65123
    10.255.0.4 (metric 30) from 10.255.0.4
      Origin IGP, aigp-metric 20, metric 0, localpref 100, valid, internal, best
  65123
    10.255.0.5 (metric 20) from 10.255.0.5
      Origin IGP, aigp-metric 40, metric 0, localpref 100, valid, internal

Compare the accumulated value plus the local cost to its next hop. R1 compares 30 + 20 = 50 against 20 + 40 = 60; R6 compares 20 + 30 = 50 against 40 + 20 = 60. Both choose the upper path. These BGP comparison totals include resolution to the border loopback, so they differ from the forwarding-path sums above by the same 10-unit loopback cost.

On the supporting command family, eligible AIGP comparisons occur after local origination and before AS-path length. Equal earlier policy is still required. AIGP is optional non-transitive and needs deliberately comparable metric scales; do not mix incompatible cost meanings or assume every vendor has identical missing-attribute behavior.

Change an interior cost

On R1 only, raise the outgoing cost of the R1–R2 link from 10 to 50. The R1–R3 link remains 30.

interface GigabitEthernet1
 ip ospf cost 50
exit
R1# show ip bgp 10.255.0.6/32
BGP routing table entry for 10.255.0.6/32
Paths: (2 available, best #2)
  65456
    10.255.0.2 (metric 60) from 10.255.0.2
      Origin IGP, aigp-metric 30, metric 0, localpref 100, valid, internal
  65456
    10.255.0.3 (metric 40) from 10.255.0.3
      Origin IGP, aigp-metric 20, metric 0, localpref 100, valid, internal, best

R1 now compares 90 through R2 with 60 through R3. Restore cost 10 on that interface after the experiment. The reverse direction is a separate calculation because this change is directional.

interface GigabitEthernet1
 ip ospf cost 10
exit

For a full baseline reset, reload the six starting configurations without the MED or AIGP policies. Before deployment, verify image support, consistent costs, intended AIGP peers, origination filters and both forwarding directions.

Key Takeaways

  • AIGP is intended for cooperating ASes inside a controlled administrative domain.
  • The metric scales must be comparable; the same IGP with inconsistent cost conventions can still mislead.
  • Enable AIGP deliberately on the intended sessions and originate it for selected infrastructure prefixes.
  • Compare accumulated cost plus local resolution cost, rather than MED alone.
  • Earlier policy still matters; AIGP support and behavior must be verified on the chosen router image.

AIGP Quiz

Six questions · four options each · select one answer per question. Submit all answers to see your score and explanations.

1. Where does the lesson use AIGP?
2. At R1, which comparison wins: 30 + 20 or 20 + 40?
3. Why can MED alone choose a poor end-to-end path?
4. What must the AIGP metric scales provide?
5. When NEXT_HOP is changed while carrying AIGP, what must be preserved?
6. Is AIGP universally enabled and supported on every router?
Protocol and command references

AIGP protocol rules · AIGP configuration and verification · Best-path comparison rules · Router-symbol attribution.