Internet路由結構學習心得一:通告匯聚和具體路由影響AS入流量1
阿新 • • 發佈:2020-10-09
BGP中通過通告匯聚路由、具體路由可以實現多宿主的主備或負載均衡,以下先記錄主備形式。
案例一:多鏈路(主備),多宿主(Multi-Homing)
思路:
針對多鏈路(主備),採用釋出sumary-only的aggregate route;針對單ISP,使用med影響入流量;使用local-pref屬性影響出流量。
案例分析:
一、針對出流量,可以使用浮動靜態路由直接指向不同的鏈路;也可以要求ISP傳送預設路由,且通過不同的Local-Preference接受並往內部發送主鏈路的預設路由。注意:這裡沒有考慮R1接受路由的情況;
二、針對入流量,由於是單ISP,可以採用med影響ISP的eBGP路由選擇;
三、可以使用BGP+aggregation的方式。從主、備兩條鏈路傳送AS內的網路彙總到ISP,且通過不同的MED,對返回流量進行控制;
具體操作:藍色部分為本地,×××為ISP;24.0.0.0/24為主鏈路,35.0.0.0/24為備用鏈路
一、R1向外釋出
二、R2、R3分別與R4、R5建立eBGP連線;
三、不考慮AS-PATH對其他AS的影響,針對BGP公告彙總路由可採用兩種方式:使用aggregate-address命令加summary-only引數,或者使用靜態路由+network方式。由於aggregate-address可通過as-set保留as-set資訊,建議使用aggregate-address和summary-only方式;
四、使用route-map SET_LOCAL_PREF in,修改兩個入口Local-Pref值,確保出流量採用主鏈路;同時使用route-map SET_MED out,修改兩個出口的med值,確保入流量採用主鏈路。
主要配置:(R2、R3配置相似,R4、R5配置相似)
hostname R1
!
interface Loopback0
ip address 1.0.0.1 255.255.255.0
!
interface Loopback1
ip address 1.0.1.1 255.255.255.0
!
interface Loopback2
ip address 1.0.2.1 255.255.255.0
!
interface Loopback3
ip address 1.0.3.1 255.255.255.0
!
interface Serial0/0
description To Gateway R2
ip address 172.16.12.1 255.255.255.0
!
interface Serial0/1
description To Gateway R3
ip address 172.16.13.1 255.255.255.0
!
router eigrp 65001
passive-interface Loopback0
passive-interface Loopback1
passive-interface Loopback2
passive-interface Loopback3
network 1.0.0.0 0.0.3.255
network 172.16.12.1 0.0.0.0
network 172.16.13.1 0.0.0.0
no auto-summary
eigrp router-id 1.1.1.1
!
end ------------------------------------------- hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Serial0/0
ip address 172.16.12.2 255.255.255.0
!
interface Serial0/1
ip address 172.16.23.2 255.255.255.0
!
interface Serial0/2
description To ISP R4
ip address 24.0.0.2 255.255.255.0
!
router eigrp 65001
network 2.2.2.2 0.0.0.0
network 172.16.12.2 0.0.0.0
network 172.16.23.2 0.0.0.0
passive-interface Loopback0
no auto-summary
eigrp router-id 2.2.2.2
!
router bgp 65001
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 1.0.0.0 mask 255.255.255.0
network 1.0.1.0 mask 255.255.255.0
network 1.0.2.0 mask 255.255.255.0
network 1.0.3.0 mask 255.255.255.0
aggregate-address 1.0.0.0 255.255.252.0 summary-only
neighbor Local_AS peer-group
neighbor Local_AS remote-as 65001
neighbor Local_AS update-source Loopback0
neighbor Local_AS next-hop-self
neighbor REMOTE_1 peer-group
neighbor REMOTE_1 remote-as 1
neighbor REMOTE_1 route-map SET_LOCAL_PREF in
neighbor REMOTE_1 route-map SET_MED out
neighbor 3.3.3.3 peer-group Local_AS
neighbor 24.0.0.4 peer-group REMOTE_1
no auto-summary
!
ip as-path access-list 10 permit ^$
!
ip prefix-list BGP_AGGREGATE seq 5 permit 1.0.0.0/22
!
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
!
route-map SET_LOCAL_PREF permit 10
match ip address prefix-list DEFAULT
set local-preference 200
!
route-map SET_LOCAL_PREF permit 20
!
route-map SET_MED permit 10
match ip address prefix-list BGP_AGGREGATE
set metric 200
!
route-map SET_MED permit 20
match as-path 10
!
end ------------------------------------------------------- hostname R4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Serial0/0
ip address 24.0.0.4 255.255.255.0
!
interface Serial0/1
ip address 45.0.0.4 255.255.255.0
!
router bgp 1
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor REMOTE_65001 peer-group
neighbor REMOTE_65001 remote-as 65001
neighbor REMOTE_65001 default-originate
neighbor LOCAL_AS peer-group
neighbor LOCAL_AS remote-as 1
neighbor LOCAL_AS update-source Loopback0
neighbor LOCAL_AS next-hop-self
neighbor 5.5.5.5 peer-group LOCAL_AS
neighbor 24.0.0.2 peer-group REMOTE_65001
no auto-summary
!
ip route 5.5.5.5 255.255.255.255 Serial0/1
!
end 說明:當沒有紅色字型部分語句時,R4、R5接收所有AS內部路由: R4#show ip route bgp
1.0.0.0/24 is subnetted, 4 subnets
B 1.0.1.0 [20/2297856] via 24.0.0.2, 00:04:01 //BGP使用EIGRP作為其metric
B 1.0.0.0 [20/2297856] via 24.0.0.2, 00:04:01
B 1.0.3.0 [20/2297856] via 24.0.0.2, 00:04:01
B 1.0.2.0 [20/2297856] via 24.0.0.2, 00:04:01 R5#show ip route bgp
1.0.0.0/24 is subnetted, 4 subnets
B 1.0.1.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.0.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.3.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.2.0 [20/2297856] via 35.0.0.3, 00:00:55 採用了aggregate-address summary-only後,所有具體路由均被抑制,併產生atomic-aggregate標記,以表示該路由為彙總路由; R2#show ip bgp 1.0.0.0 255.255.255.0
BGP routing table entry for 1.0.0.0/24, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table, Advertisements suppressed by an aggregate.)
Not advertised to any peer
Local
172.16.12.1 from 0.0.0.0 (2.2.2.2)
Origin IGP, metric 2297856, localpref 100, weight 32768, valid, sourced, local, best R2#show ip bgp 1.0.0.0 255.255.252.0
BGP routing table entry for 1.0.0.0/22, version 12
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1 2
Local, (aggregated by 65001 3.3.3.3)
3.3.3.3 (metric 2297856) from 3.3.3.3 (3.3.3.3)
Origin IGP, metric 0, localpref 100, valid, internal, atomic-aggregate
Local, (aggregated by 65001 2.2.2.2)
0.0.0.0 from 0.0.0.0 (2.2.2.2)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate, best ISP端R4、R5的路由表減少了路由數目: R4#show ip route bgp
1.0.0.0/22 is subnetted, 1 subnets
B 1.0.0.0 [20/0] via 24.0.0.2, 00:01:13 ////BGP使用Connected作為其metric
R5#show ip route bgp
1.0.0.0/22 is subnetted, 1 subnets
B 1.0.0.0 [20/0] via 35.0.0.3, 00:00:51
雖然成功減少了ISP路由表的大小,但是這裡並沒有實現主備鏈路的功能,所有R5接收到的資料包仍舊通過eBGP轉發到R3,我們的目的是所有資料包都往R2傳送。因此我們使用綠色字型的配置修改從ISP傳送過來預設路由的local-pref值,使本地所有出流量傳送至R2;使用藍色字型的配置修改傳送到ISP彙總路由的MED值,使其選擇R2為本地目的地的下一跳。 R4#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/22 24.0.0.2 200 0 65001 i show ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i1.0.0.0/22 4.4.4.4 200 100 0 65001 i
* 35.0.0.3 300 0 65001 i 案例總結:採用多鏈路(主備)形式作為出口的,可使所有出口通告同樣的匯聚路由,並修改MED屬性使外部路由器選擇最優路由。
interface Loopback0
ip address 1.0.0.1 255.255.255.0
!
interface Loopback1
ip address 1.0.1.1 255.255.255.0
!
interface Loopback2
ip address 1.0.2.1 255.255.255.0
!
interface Loopback3
ip address 1.0.3.1 255.255.255.0
!
interface Serial0/0
description To Gateway R2
ip address 172.16.12.1 255.255.255.0
!
interface Serial0/1
ip address 172.16.13.1 255.255.255.0
!
router eigrp 65001
passive-interface Loopback0
passive-interface Loopback1
passive-interface Loopback2
passive-interface Loopback3
network 1.0.0.0 0.0.3.255
network 172.16.12.1 0.0.0.0
network 172.16.13.1 0.0.0.0
no auto-summary
eigrp router-id 1.1.1.1
end ------------------------------------------- hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Serial0/0
ip address 172.16.12.2 255.255.255.0
!
interface Serial0/1
ip address 172.16.23.2 255.255.255.0
!
interface Serial0/2
description To ISP R4
ip address 24.0.0.2 255.255.255.0
!
router eigrp 65001
network 2.2.2.2 0.0.0.0
network 172.16.12.2 0.0.0.0
network 172.16.23.2 0.0.0.0
passive-interface Loopback0
no auto-summary
eigrp router-id 2.2.2.2
!
router bgp 65001
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 1.0.0.0 mask 255.255.255.0
network 1.0.1.0 mask 255.255.255.0
network 1.0.2.0 mask 255.255.255.0
network 1.0.3.0 mask 255.255.255.0
aggregate-address 1.0.0.0 255.255.252.0 summary-only
neighbor Local_AS peer-group
neighbor Local_AS remote-as 65001
neighbor Local_AS update-source Loopback0
neighbor Local_AS next-hop-self
neighbor REMOTE_1 peer-group
neighbor REMOTE_1 remote-as 1
neighbor REMOTE_1 route-map SET_LOCAL_PREF in
neighbor REMOTE_1 route-map SET_MED out
neighbor 3.3.3.3 peer-group Local_AS
neighbor 24.0.0.4 peer-group REMOTE_1
no auto-summary
!
ip as-path access-list 10 permit ^$
!
ip prefix-list BGP_AGGREGATE seq 5 permit 1.0.0.0/22
!
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
!
route-map SET_LOCAL_PREF permit 10
match ip address prefix-list DEFAULT
set local-preference 200
!
route-map SET_LOCAL_PREF permit 20
!
route-map SET_MED permit 10
match ip address prefix-list BGP_AGGREGATE
set metric 200
!
route-map SET_MED permit 20
match as-path 10
!
end ------------------------------------------------------- hostname R4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Serial0/0
ip address 24.0.0.4 255.255.255.0
!
interface Serial0/1
ip address 45.0.0.4 255.255.255.0
!
router bgp 1
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor REMOTE_65001 peer-group
neighbor REMOTE_65001 remote-as 65001
neighbor REMOTE_65001 default-originate
neighbor LOCAL_AS peer-group
neighbor LOCAL_AS remote-as 1
neighbor LOCAL_AS update-source Loopback0
neighbor LOCAL_AS next-hop-self
neighbor 5.5.5.5 peer-group LOCAL_AS
neighbor 24.0.0.2 peer-group REMOTE_65001
no auto-summary
!
ip route 5.5.5.5 255.255.255.255 Serial0/1
!
end 說明:當沒有紅色字型部分語句時,R4、R5接收所有AS內部路由: R4#show ip route bgp
1.0.0.0/24 is subnetted, 4 subnets
B 1.0.1.0 [20/2297856] via 24.0.0.2, 00:04:01 //BGP使用EIGRP作為其metric
B 1.0.0.0 [20/2297856] via 24.0.0.2, 00:04:01
B 1.0.3.0 [20/2297856] via 24.0.0.2, 00:04:01
B 1.0.2.0 [20/2297856] via 24.0.0.2, 00:04:01 R5#show ip route bgp
1.0.0.0/24 is subnetted, 4 subnets
B 1.0.1.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.0.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.3.0 [20/2297856] via 35.0.0.3, 00:00:55
B 1.0.2.0 [20/2297856] via 35.0.0.3, 00:00:55 採用了aggregate-address summary-only後,所有具體路由均被抑制,併產生atomic-aggregate標記,以表示該路由為彙總路由; R2#show ip bgp 1.0.0.0 255.255.255.0
BGP routing table entry for 1.0.0.0/24, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table, Advertisements suppressed by an aggregate.)
Not advertised to any peer
Local
172.16.12.1 from 0.0.0.0 (2.2.2.2)
Origin IGP, metric 2297856, localpref 100, weight 32768, valid, sourced, local, best R2#show ip bgp 1.0.0.0 255.255.252.0
BGP routing table entry for 1.0.0.0/22, version 12
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1 2
Local, (aggregated by 65001 3.3.3.3)
3.3.3.3 (metric 2297856) from 3.3.3.3 (3.3.3.3)
Origin IGP, metric 0, localpref 100, valid, internal, atomic-aggregate
Local, (aggregated by 65001 2.2.2.2)
0.0.0.0 from 0.0.0.0 (2.2.2.2)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate, best ISP端R4、R5的路由表減少了路由數目: R4#show ip route bgp
1.0.0.0/22 is subnetted, 1 subnets
B 1.0.0.0 [20/0] via 24.0.0.2, 00:01:13 ////BGP使用Connected作為其metric
R5#show ip route bgp
1.0.0.0/22 is subnetted, 1 subnets
B 1.0.0.0 [20/0] via 35.0.0.3, 00:00:51
雖然成功減少了ISP路由表的大小,但是這裡並沒有實現主備鏈路的功能,所有R5接收到的資料包仍舊通過eBGP轉發到R3,我們的目的是所有資料包都往R2傳送。因此我們使用綠色字型的配置修改從ISP傳送過來預設路由的local-pref值,使本地所有出流量傳送至R2;使用藍色字型的配置修改傳送到ISP彙總路由的MED值,使其選擇R2為本地目的地的下一跳。 R4#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/22 24.0.0.2 200 0 65001 i show ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i1.0.0.0/22 4.4.4.4 200 100 0 65001 i
* 35.0.0.3 300 0 65001 i 案例總結:採用多鏈路(主備)形式作為出口的,可使所有出口通告同樣的匯聚路由,並修改MED屬性使外部路由器選擇最優路由。