In this scenario, you build upon the IBGP network and configure EBGP on R1 and R2 and simulate a dual-homing ISP connection. Because most CCNP candidates do not have two ISP connections to configure in a lab environment, you configure two routers and inject default routes along with a large IP routing table to simulate an ISP router.
Configure the routers ISP1 and ISP2 for EBGP and advertise a default route to the internal BGP network along with some routes that simulate an Internet environment.configures ISP1(R6) for EBGP and allows a default route to be advertised to the EBGP peer to R1.
برای R7 یا همان ISP2 نیز کار فوق را انجام میدهیم ودر آخر خروجی R1 را بررسی میکنیم که به شکل زیر می باشد...
برای شبکه اینترنت یا 0.0.0.0 دو مسیر بصورت redundant وجود دارد که در شکل دیده میشود.(بعد از ایجاد همسایگی بین ISP ها با روتر های متناظر در شبکه)
Similarly, because R2 has a direct connection to the EBGP peer to ISP2, R2 selects ISP2 for all default-based traffic. This means that traffic is sent to different ISP routers for any traffic to the Internet. This traffic pattern is undesirable because IP packets might take different paths and not reach the destination in a timely manner, resulting in loss or slow user-data transfer, such as HTTP traffic.
Ideally, a dual-home connection is for redundancy purposes only. Configure R2 to send all default traffic through the connection on R1 to ISP1, unless R1 loses the connection to ISP1.
To accomplish this task, you modify the MED value on R2 to ensure that all default traffic is sent through R1. Lower MED values are preferred, and MED influences only EBGP connections.
R2(config)#router bgp 333
R2(config-router)#neighbor 131.108.254.1 route-map setmedr1 in
R2(config-router)#neighbor 160.100.1.1 route-map setmedisp2 in
R2(config)#access-list 1 permit 0.0.0.0
R2(config)#route-map setmedr1
R2(config-route-map)#match ip address 1
R2(config-route-map)#set metric 100
R2(config)#route-map setmedisp2
R2(config-route-map)#match ip address 1
R2(config-route-map)#set metric 200
the preferred path to the next hop 160.100.1.1, even though the MED is lower, is through ISP2.
The MED attribute is compared only for paths from neighbors in the same AS.
R1 (in AS 333) and ISP2 (in AS 4000) are in different autonomous systems, so to enable BGP to compare MED in different autonomous systems, you must enable the bgp always-compare-med command.
The bgp always-compare-med command allows the MED values to be compared, and BGP decisions are even though the two routers, R1 and R2, are in different autonomous systems.
R2(config)#router bgp 333
R2(config-router)#bgp always-compare-med
در شکل زیر بعد از دستور مقایسه MED در AS های متفاوت و دستور تغییر MED ،خروجیR2 به شکل زیر در آمد
در شکل مشاهده میشود که مسیر 171.108.1.1 که دارای MED کمتری نسبت به مسیر 160.100.1.1 است (برای 0.0.0.0) بعنوان مسیر بهتر معرفی شده...
R2 configs using MED:
router ospf 1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 333
no synchronization
bgp always-compare-med
bgp log-neighbor-changes
network 131.108.1.0 mask 255.255.255.0
neighbor 131.108.254.1 remote-as 333
neighbor 131.108.254.1 update-source Loopback0
neighbor 131.108.254.1 route-map setmedr1 in
neighbor 131.108.254.3 remote-as 333
neighbor 131.108.254.3 update-source Loopback0
neighbor 131.108.254.3 route-reflector-client
neighbor 131.108.254.4 remote-as 333
neighbor 131.108.254.4 update-source Loopback0
neighbor 131.108.254.4 route-reflector-client
neighbor 131.108.254.5 remote-as 333
neighbor 131.108.254.5 update-source Loopback0
neighbor 131.108.254.5 route-reflector-client
neighbor 160.100.1.1 remote-as 4000
neighbor 160.100.1.1 route-map setmedisp2 in
no auto-summary
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
access-list 1 permit 0.0.0.0
!
!
!
route-map setmedr1 permit 10
match ip address 1
set metric 100
!
route-map setmedisp2 permit 10
match ip address 1
set metric 200
توضیح خطوط بولدشده :
برای مسیر 0.0.0.0 اگر از 131.108.254.1 بیایی ، MED برابر 100 میباشد ولی اگر از مسیر 160.100.1.1 بیایی ، MED برابر 200 میباشد...بنابراین برای رفتن به 0.0.0.0 (اگر مسیر از R2 بود) ، ترجیحا از 131.108.254.1 خارج خواهیم شد.چونکه دارای MED کمتری میباشد...
در این قسمت قصد داریم در R2 دستوری بنویسیم تا AS-Path را دستکاری بکند (AS-Path اضافه کند) ، تا با ستفاده از اینکار کمترین AS-Path تغییر کند...
R2(config-router)#no neighbor 160.100.1.1 route-map setmedisp2 in
R2(config-router)#no neighbor 131.108.254.1 route-map setmedr1 in
R2(config-router)#neighbor 160.100.1.1 route-map aspath in
R2(config-route-map)#set as-path prepend 4000 3999 3998
با اضافه کردن as-path های 4000 و 3999 و 3998 ،به مسیر 160.100.1.1 خروجی R2 را مشاهده کنید...
R2 now prefers the path through the next hop address 171.108.1.1 (R1's link to ISP1) because the AS_Path is only 50001 (one hop), or a lower hop count away compared to 4000 3999 3998 (three hops).
Some other common configurations completed on routers connected to the Internet include the following:
· Ensuring that only a default route is accepted
· Ensuring that you are not a transit path for any Internet traffic
Next, configure R1 and R2 to accept only a default route and ensure that the service providers, ISP1 and ISP2, do not use the network between R1 and R2 as a transit path.
The no-export community attribute advises a BGP router carrying this attribute that the route advertised should not be advertised to any peers outside the AS.