BGP Autonomous Systems
:私有:64512-65535
--- An AS allows packets to transit through it to reach other autonomous systems(for example ,it si a service provider).
---
An AS has multiple connections to other autonomous systems.
--Routing policy and route selection for traffic entering and leaving the AS must be manipulated.
BGP is not always appropriate,You do not have to use BGP if you have one of the following conditions:
---Limited understanding of route filtering and BGP path-selection process.
---A single connection to the Internet or another AS
---Lack of memory or processor power to handle constant updates on BGP routers.
---Reliable updates:runs on top of TCP (port 179)
---Incremental,triggered updates only
---Periodic keep-alive messages to verify TCP connectivity
---Rich metrics (called path vectors or attributes)
---Designed to scale to huge inter-networks(for example,the Internet)
BGP Databases(三张表)
--List of BGP neighbors
---List of all networks learned from each neighbor
---Can contain multiple paths to destination networks
---Contains BGP attributes for each path
---List of best paths to destination networks
---Includes hold time and BGP router ID
---Information for one path only(could be to multiple networks)
---Includes path attributes and networks
---When error is detected
---BGP connection closed after message is sent
通告路由
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor 24.1.1.2 remote-as 1
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 24.1.1.4 remote-as 4
BGP version 4, remote router ID 4.4.4.4
BGP state = Established, up for 00:02:00
Last read 00:00:03, last write 00:00:00, hold time is 180, keepalive interval is 60 seconds
Neighbor sessions:
1 active, is not multisession capable (disabled)
Neighbor capabilities:
Route refresh: advertised and received(new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Enhanced Refresh Capability: advertised and received
Multisession Capability:
Stateful switchover support enabled: NO for session 1
Message statistics:
InQ depth is 0
OutQ depth is 0
Sent
Rcvd
Opens:
1
1
Notifications:
0
0
Updates:
1
1
Keepalives:
3
3
Route Refresh:
0
0
Total:
5
5
Default minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
Session: 24.1.1.4
BGP table version 1, neighbor version 1/0
Output queue size : 0
Index 1, Advertise bit 0
1 update-group member
Slow-peer detection is disabled
Slow-peer split-update-group dynamic is disabled
Sent
Rcvd
Prefix activity:
----
----
Prefixes Current:
0
0
Prefixes Total:
0
0
Implicit Withdraw:
0
0
Explicit Withdraw:
0
0
Used as bestpath:
n/a
0
Used as multipath:
n/a
0
Outbound
Inbound
Local Policy Denied Prefixes:
--------
-------
Total:
0
0
Number of NLRIs in the update sent: max 0, min 0
Last detected as dynamic slow peer: never
Dynamic slow peer recovered: never
Refresh Epoch: 1
Last Sent Refresh Start-of-rib: never
Last Sent Refresh End-of-rib: never
Last Received Refresh Start-of-rib: never
Last Received Refresh End-of-rib: never
Sent
Rcvd
Refresh activity:
----
----
Refresh Start-of-RIB
0
0
Refresh End-of-RIB
0
0
Address tracking is enabled, the RIB does have a route to 24.1.1.4
Connections established 1; dropped 0
Last reset never
Transport(tcp) path-mtu-discovery is enabled
Graceful-Restart is disabled
Packets received in fast path: 0, fast processed: 0, slow path: 0
fast lock acquisition failures: 0, slow path: 0
router-id 2.2.2.2
network 2.2.2.0 0.0.0.255 area 0
network 12.1.1.0 0.0.0.255 area 0
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 update-source Loopback0
neighbor 24.1.1.4 remote-as 4
router-id 1.1.1.1
network 12.1.1.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
router-id 3.3.3.3
network 3.3.3.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 1
neighbor 2.2.2.2 update-source Loopback0
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Network
Next Hop
Metric LocPrf Weight Path
*>
4.4.4.0/24
0.0.0.0
0
32768 i
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Network
Next Hop
Metric LocPrf Weight Path
*>
4.4.4.0/24
24.1.1.4
0
0 4 i
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Network
Next Hop
Metric LocPrf Weight Path
* i 4.4.4.0/24
24.1.1.4
0
100
0 4 i
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Network
Next Hop
Metric LocPrf Weight Path
*>i 4.4.4.0/24
2.2.2.2
0
100
0 4 i
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor aaa peer-group
neighbor aaa remote-as 1
neighbor aaa update-source Loopback0
neighbor 2.2.2.2 peer-group aaa
neighbor 3.3.3.3 peer-group aaa
bgp router-id 4.4.4.4
bgp log-neighbor-changes
network 4.4.4.0 mask 255.255.255.0
neighbor 24.1.1.2 remote-as 1
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor aaa peer-group
neighbor aaa remote-as 1
neighbor aaa update-source Loopback0
neighbor aaa next-hop-self
neighbor 1.1.1.1 peer-group aaa
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 24.1.1.4 remote-as 4
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor aaa peer-group
neighbor aaa remote-as 1
neighbor aaa update-source Loopback0
neighbor 2.2.2.2 peer-group aaa
neighbor 3.3.3.3 peer-group aaa
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor aaa peer-group
neighbor aaa remote-as 1
neighbor aaa update-source Loopback0
neighbor aaa next-hop-self
neighbor 1.1.1.1 peer-group aaa
neighbor 2.2.2.2 remote-as 1
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 5.5.5.5 remote-as 5
neighbor 5.5.5.5 ebgp-multihop 2
neighbor 5.5.5.5 update-source Loopback0
bgp log-neighbor-changes
network 5.5.5.0 mask 255.255.255.0
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback0
AS号:公有 0-64511
AS号查询
http://www.cidr-report.org/as6447/autnums.html
BGP Path-Vector Routing
AS相当于一个大路由器
AS-by-AS
BGP
Characteristics
BGP is most appropriate when at least one of the following
conditions exists:
电信---网通
1、管理
2、OSPF 10000条,ISIS,20000条,internet 10几万条
3、BGP策略路由
4、 ---扩展应用,ipv4、ipv6、vpnv4、MPLS
BGP Characteristic(Count.)
BGP is a path-vector protocol with the follow
enhancements over distance vector protocols:
BGP Databases(三张表)
Neighbor table
BGP table(forwarding database)
IP routing table
不做负载均衡
AD
IBGP
200
EBGP 20
BGP Message Types
BGP defines the following message types:
Open
Keepalive
Update
Notification
_______________________________________________________________________
Explaining EBGP and IBGP
Peers = Neighbors
- A "BGP peer," also known as a "BGP neighbor," is a specific term that is used for BGP speakers that have established a neighbor relationship
- Any two routers that have formed a TCP connection to exchange BGP routing Information are called BGP peers or BGP neighbors.
External BGP
- When BGP is running between neighbors that belong to different autonomous systems,it is called EBGP.
- EBGP neighbors,by default,need to be directly connected.
Internal BGP
- When BGP is running between neighbors within the save AS,it is called IBGP
- The neighbors do not have to be directly connected.
IBGP in a Transit AS (ISP)
- Redistributing BGP into an IGP (OSPF in this example) is not recommended.
- Instead,run IBGP on all routers.
解决路由黑洞
1、物理线路FULL MESH
2、BGP邻居的FULL MESH
3、将BGP重分布到IGP(LAB)
4、MPLS( 最好的解决方案)
IBGP In a NonTransit AS
EBGP水平分割
不接收含有本AS号的BGP路由。
IBGP
By default,routers learned via IBGP are never propagated to
other IBGP peers,so they need full-mesh IBGP
有条件的打破 IGBP水平分割。
network hello邻居
EBGP
Neighbor
network
R4上的配置
router bgp 4
R2上的配置
router bgp 1
R4#show ip bgp summary
BGP router identifier 4.4.4.4, local AS number 4
BGP table version is 1, main routing table version 1
Neighbor
V
AS MsgRcvd MsgSent
TblVer
InQ OutQ Up/Down
State/PfxRcd
24.1.1.2
4
1
14
14
1
0
0 00:09:22
0
R2#show ip bgp neighbors
BGP neighbor is 24.1.1.4,
remote
AS 4, external link
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 1
Local host: 24.1.1.2, Local port: 179
Foreign host: 24.1.1.4, Foreign port: 48615
Connection tableid (VRF): 0
Maximum output segment queue size: 50
Enqueued packets for retransmit: 0, input: 0
mis-ordered: 0 (0 bytes)
Event Timers (current time is 0x31CD9):
Timer
Starts
Wakeups
Next
Retrans
5
0
0x0
TimeWait
0
0
0x0
AckHold
4
2
0x0
SendWnd
0
0
0x0
KeepAlive
0
0
0x0
GiveUp
0
0
0x0
PmtuAger
0
0
0x0
DeadWait
0
0
0x0
Linger
0
0
0x0
ProcessQ
0
0
0x0
iss: 3917151808
snduna: 3917151946
sndnxt: 3917151946
irs: 1610121879
rcvnxt: 1610122017
sndwnd:
16247
scale:
0
maxrcvwnd:
16384
rcvwnd:
16247
scale:
0
delrcvwnd:
137
SRTT: 487 ms, RTTO: 3168 ms, RTV: 2681 ms, KRTT: 0 ms
minRTT: 7 ms, maxRTT: 1000 ms, ACK hold: 200 ms
Status Flags: passive open, gen tcbs
Option Flags: nagle, path mtu capable
IP Precedence value : 6
Datagrams (max data segment is 1460 bytes):
Rcvd: 11 (out of order: 0), with data: 5, total data bytes: 137
Sent: 10 (retransmit: 0, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 5, total data bytes: 137
TCP Semaphore
0xF49FCF8C
FREE
R2#show tcp brief
TCB
Local Address
Foreign Address
(state)
F1559798
24.1.1.2.179
24.1.1.4.48615
ESTAB
F4BFA5F8
2.2.2.2.17210
3.3.3.3.179
ESTAB
IBGP建议用环回接口建邻居。
更新源
NEI 24.1.1.2
NEI 24.1.1.4
US:24.1.1.4
US 24.1.1.2
NEI 3.3.3.3 NEI 2.2.2.2
US 12.1.1.2 US13.1.1.3
R2上的配置
router ospf 110
router bgp 1
R1上的配置
router ospf 1
R3上的配置
router ospf 110
router bgp 1
Example ebgp-multihop command
A路由器配置
router bgp 65102
neighbor 1.1.1.1 remote-as 65101
neighbor 1.1.1.1 update-source Loopback 0
neighbor 1.1.1.1 ebgp-multihop 2
ip route 1.1.1.1 255.255.255.255 192.168.1.18
ip route 1.1.1.1 255.255.255.255 192.168.1.34
B路由器配置
router bgp 65101
neighbor 2.2.2.2 remote-as 65102
neighbor 2.2.2.2 update-source Loopback 0
neighbor 2.2.2.2 ebgp-multihop 2
ip route 2.2.2.2 255.255.255.255 192.168.1.17
ip route 2.2.2.2 255.255.255.255 192.168.1.33
R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
*:为可用的,>:最优的路由
R2#show ip bgp
BGP table version is 2, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
R3#show ip bgp
BGP table version is 1, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
没有>:(不优的路由)
1、不会进路由表。
2、不会给其他BGP邻居传。
BGP路由优的条件:
1、同步(从IGP学习到/no syn)
2、下一跳
R3(config)#router bgp 1
R3(config-router)#no sy
R3(config-router)#no synchronization
R2(config-router)#neighbor 3.3.3.3 next-hop-self
R3#show ip bgp
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
BGP Synchronization
Synchronization rule:Do not use or advertise to an external neighbor a route learned by IBGP until a
matching route has been learned from an IGP
-
Ensures consistency of information throughout the AS -
Safe to have it off only if all routers in the transit path in the AS are running full-mes IBGP:off by default in Cisco software release 12.2(8)
Router(config-router)#
no synchronization
-
Disables BGP synchronization so that a router will advertise routes in IGP without learning them in an IGP
Router (config-router)#
synchronization
- Enables BGP synchronization so that a router will not advertise routers in BGP until it learns them in an IGP
Using a peer group
Router(config-router)#
neighbor
peer-group-name peer-group
- This command creates a peer group.
Router(config-router)#
neighbor
ip-address peer-group
peer-group-name
- This command defines a template with parameters set for a group of neighbors instead of individually.
- This command is useful when many neighbors have the same outbound policies.
- Members can have a different inbound policy.
- Updates are generated once per peer group.
- Configuration is simplified.
R1#show run | b r b
router bgp 1
R4#show run | b r b
router bgp 4
R2#show run | b r b
router bgp 1
R1#show run | b r b
router bgp 1
R3#show run | b r b
router bgp 1
!
R5#show run | b r b
router bgp 5
!