All routers have a loopback 0 interface X.X.X.X/32 where X is the number of the router.
Configure OSPF on R1, R2, R3 and advertise 10.10.12.0/24, 10.10.13.0/24 and loopback 0 subnets
Configure OSPF on R4, R5 and advertise 150.45.45.0/26 and loopback 0 subnets
Configure full iBGP mesh in AS 123, use loopback 0 interface for peering
Configure iBGP in AS 45, use loopback 0 interface for peering
Configure eBGP between AS 123 and AS 45
Advertise R1 loopback 0 and 150.45.45.0/26 in BGP
Ensure AS 123 will use the link between R3-R5 towards network 150.45.45.0/26. Use MED attribute only.
Ensure AS 45 will use the link between R3-R5 towards network 1.1.1.1/32. Use MED attribute only.
all configs
..............................................................
R1 or R6
router ospf 10
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 0
network 10.10.12.0 0.0.0.255 area 0
network 10.10.13.0 0.0.0.255 area 0
!
router bgp 123
no synchronization
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 123
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
R2
router ospf 10
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 0
network 10.10.12.0 0.0.0.255 area 0
!
router bgp 123
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 24.0.0.2 remote-as 45
neighbor 24.0.0.2 route-map RM-SET-MED out
no auto-summary
!
ip forward-protocol nd
!
!
ip http server
no ip http secure-server
!
!
ip prefix-list NET-1 seq 5 permit 1.1.1.1/32
!
!
!
route-map RM-SET-MED permit 10
match ip address prefix-list NET-1
set metric 20
R3
router ospf 10
log-adjacency-changes
network 3.3.3.3 0.0.0.0 area 0
network 10.10.13.0 0.0.0.255 area 0
!
router bgp 123
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 123
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 35.0.0.2 remote-as 45
neighbor 35.0.0.2 route-map RM-SET-MED out
no auto-summary
!
ip forward-protocol nd
!
!
ip http server
no ip http secure-server
!
!
ip prefix-list NET-1 seq 5 permit 1.1.1.1/32
!
!
!
route-map RM-SET-MED permit 10
match ip address prefix-list NET-1
set metric 10
!
R4
router ospf 100
log-adjacency-changes
network 4.4.4.4 0.0.0.0 area 0
network 150.45.45.4 0.0.0.0 area 0
!
router bgp 45
no synchronization
bgp log-neighbor-changes
network 150.45.45.0 mask 255.255.255.192
neighbor 5.5.5.5 remote-as 45
neighbor 5.5.5.5 update-source Loopback0
neighbor 5.5.5.5 next-hop-self
neighbor 24.0.0.1 remote-as 123
neighbor 24.0.0.1 route-map RM-SET-MED out
no auto-summary
!
ip forward-protocol nd
!
!
ip http server
no ip http secure-server
!
!
ip prefix-list NET-150 seq 5 permit 150.45.45.0/26
!
!
!
route-map RM-SET-MED permit 10
match ip address prefix-list NET-150
set metric 20
R5
router ospf 100
log-adjacency-changes
network 5.5.5.5 0.0.0.0 area 0
network 150.45.45.5 0.0.0.0 area 0
!
router bgp 45
no synchronization
bgp log-neighbor-changes
network 150.45.45.0 mask 255.255.255.192
neighbor 4.4.4.4 remote-as 45
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 35.0.0.1 remote-as 123
neighbor 35.0.0.1 route-map RM-SET-MED out
no auto-summary
!
ip forward-protocol nd
!
!
ip http server
no ip http secure-server
!
!
ip prefix-list NET-150 seq 5 permit 150.45.45.0/26
!
!
!
route-map RM-SET-MED permit 10
match ip address prefix-list NET-150
set metric 10
........................................................
حال با trace کردن به صور زیر قادر خواهیم بود صحت تنظیمات خود را ببینیم
traceroute 150.45.45.5 source 1.1.1.1 (R1(R6)#traceroute 150.45.45.5 source lo 0
)
traceroute 1.1.1.1 source 150...45.45.5 (R5#traceroute 1.1.1.1 source fastethernet 0/0
)
Keep in mind that R4 and R5 have only route to 1.1.1.1/32 in AS 123 and that if you do traceroute 150.45.45.5 from R1, it will by default IP of outgoing interface as a source IP (in this case 10.10.13.1), to which R4 and R5 don't have a route.
Always consider not only if your side have a route to the destination but also if the remote side has a route back to you.