实验11 BGP基本配置

实验任务一 IBGP和EBGP的建立
1.建立物理连接

2.RTB,RTC,RTD私网互通
[RTB]ip route-static 4.4.4.4 32 10.10.10.6
[RTB]ip route-static 3.3.3.3 32 10.10.10.6
[RTC]ip route-static 2.2.2.2 32 10.10.10.5
[RTC]ip route-static 4.4.4.4 32 10.10.10.9
[RTD]ip route-static 2.2.2.2 32 10.10.10.10
[RTD]ip route-static 3.3.3.3 32 10.10.10.10
3.BGP对等体的基本配置
[RTA]bgp 65000
[RTA-bgp-default]peer 10.10.10.2 as-number 65300
[RTA-bgp-default]peer 10.10.20.2 as-number 65300
[RTA-bgp-default]address-family ipv4 unicast
[RTA-bgp-default-ipv4]peer 10.10.10.2 enable
[RTA-bgp-default-ipv4]peer 10.10.20.2 enable

[RTB]bgp 65300
[RTB-bgp-default]peer 10.10.10.1 as-number 65000
[RTB-bgp-default]peer 3.3.3.3 as-number 65300
[RTB-bgp-default]peer 3.3.3.3 connect-interface LoopBack 0
[RTB-bgp-default]peer 4.4.4.4 as-number 65300
[RTB-bgp-default]peer 4.4.4.4 connect-interface LoopBack 0
//以loopback0的ip地址作为IBGP连接的源地址。
[RTB-bgp-default]address-family ipv4 unicast
[RTB-bgp-default-ipv4]peer 10.10.10.1 enable
[RTB-bgp-default-ipv4]peer 3.3.3.3 enable
[RTB-bgp-default-ipv4]peer 4.4.4.4 enable
原因为:假如指定某一个物理端口,物理端口down就直接BGP连接失败,但是loopback口的话,即使一个物理口down了,BGP连接还可以成功。

[RTC]bgp 65300
[RTC-bgp-default]peer 2.2.2.2 as-number 65300
[RTC-bgp-default]peer 4.4.4.4 as-number 65300
[RTC-bgp-default]peer 2.2.2.2 connect-interface LoopBack 0
[RTC-bgp-default]peer 4.4.4.4 connect-interface LoopBack 0
[RTC-bgp-default]address-family ipv4 unicast
[RTC-bgp-default-ipv4]peer 2.2.2.2. enable
[RTC-bgp-default-ipv4]peer 4.4.4.4 enable

[RTD]bgp 65300
[RTD-bgp-default]peer 10.10.20.1 as-number 65000
[RTD-bgp-default]peer 2.2.2.2 as-number 65300
[RTD-bgp-default]peer 2.2.2.2 connect-interface LoopBack 0
[RTD-bgp-default]peer 3.3.3.3 as-number 65300
[RTD-bgp-default]peer 3.3.3.3 connect-interface LoopBack 0
[RTD-bgp-default]address-family ipv4 unicast
[RTD-bgp-default-ipv4]peer 2.2.2.2 enable
[RTD-bgp-default-ipv4]peer 3.3.3.3 enable
[RTD-bgp-default-ipv4]peer 10.10.20.10 enable

当指定源端口是loopback0端口时,必须两端的源端口地址是互相对应的,否则无法建立BGP邻居,再者,AS号也要对应。
4.查看bgp基本信息
[RTA]display bgp peer ipv4//查看邻居状态

BGP local router ID: 1.1.1.1
Local AS number: 65000//本地的AS号
Total number of peers: 2 Peers in established state: 2

    • Dynamically created peer
      Peer AS MsgRcvd MsgSent OutQ PrefRcv Up/Down State

10.10.10.2 65300 34 36 0 1 00:28:15 Established
10.10.20.2 65300 25 27 0 1 00:18:05 Established

[RTA]display bgp routing-table ipv4

Total number of routes: 0

BGP主要工作是在AS之间传递路由信息,而发现和计算路由信息的任务是由IGP完成的。
生成BGP路由两个方法,配置BGP发布本地路由(network),引入其他路由(import-route)

5.通过network命令查看发布路由。
[RTA-bgp-default-ipv4]network 1.1.1.1 32
[RTB-bgp-default-ipv4]network 2.2.2.2 32
[RTD-bgp-default-ipv4]network 4.4.4.4 32

[RTA]display bgp routing-table ipv4

Total number of routes: 3

BGP local router ID is 1.1.1.1 //本地的路由id
Status codes: * - valid, > - best, d - dampened, h - history
s - suppressed, S - stale, i - internal, e - external
a - additional-path
Origin: i - IGP, e - EGP, ? - incomplete

 Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
  • 1.1.1.1/32 127.0.0.1 0 32768 i

  • e 2.2.2.2/32 10.10.10.2 0 0 65300i

  • e 4.4.4.4/32 10.10.20.2 0 0 65300i

[RTD-bgp-default]display bgp routing-table ipv4

Total number of routes: 4

BGP local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - dampened, h - history
s - suppressed, S - stale, i - internal, e - external
a - additional-path
Origin: i - IGP, e - EGP, ? - incomplete

 Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
  • e 1.1.1.1/32 10.10.20.1 0 0 65000i
    i 10.10.10.1 0 100 0 65000i

  • i 2.2.2.2/32 2.2.2.2 0 100 0 i

  • 4.4.4.4/32 127.0.0.1 0 32768 i
    下面是RTC的ip路由表
    [RTC]display ip routing-table

Destinations : 19 Routes : 19

Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 Static 60 0 10.10.10.5 GE0/0
3.3.3.3/32 Direct 0 0 127.0.0.1 InLoop0
4.4.4.4/32 Static 60 0 10.10.10.9 GE0/1
10.10.10.4/30 Direct 0 0 10.10.10.6 GE0/0
10.10.10.4/32 Direct 0 0 10.10.10.6 GE0/0
10.10.10.6/32 Direct 0 0 127.0.0.1 InLoop0
10.10.10.7/32 Direct 0 0 10.10.10.6 GE0/0
10.10.10.8/30 Direct 0 0 10.10.10.10 GE0/1
10.10.10.8/32 Direct 0 0 10.10.10.10 GE0/1
10.10.10.10/32 Direct 0 0 127.0.0.1 InLoop0
10.10.10.11/32 Direct 0 0 10.10.10.10 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
下面是RTC的BGP路由表
[RTC]display bgp routing-table ipv4

Total number of routes: 4

BGP local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - dampened, h - history
s - suppressed, S - stale, i - internal, e - external
a - additional-path
Origin: i - IGP, e - EGP, ? - incomplete

 Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

i 1.1.1.1/32 10.10.10.1 0 100 0 65000i
i 10.10.20.1 0 100 0 65000i

  • i 2.2.2.2/32 2.2.2.2 0 100 0 i

  • i 4.4.4.4/32 4.4.4.4 0 100 0 i

可以看到Bgp路由表有去1.1.1.1的路由,但是ip路由表上没有。
因为ibgp从ebgp学习到的路由,下一跳是EBGP的ip地址,发给IBGP邻居的时候,不改变下一跳,而它没有下一跳的路由,所以不能够加入ip路由表。

BGP邻居的建立是tcp可达的情况下,所以ip路由表必须有到达对端bgp源地址的路由。

原文地址:https://www.cnblogs.com/akiz/p/11148166.html