BGP的基本配置

BGPIBGP的基本配置

一、基本配置

R1(config)#interface serial  1/1

R1(config-if)#ip address  12.1.1.1 255.255.255.0

R1(config-if)#no shut

R1(config)#interface  loopback  0

R1(config-if)#ip address  1.1.1.1 255.255.255.0

R1(config-if)#exit

R2(config)#in serial 1/1

R2(config-if)#ip address  23.1.1.1 255.255.255.0

R2(config-if)#no shut

R2(config)#interface  serial  1/0

R2(config-if)#ip address  12.1.1.2 255.255.255.0

R2(config-if)#no shut

R2(config)#in loopback 0

R2(config-if)#ip address  2.2.2.2 255.255.255.0

R1/R2/R3/R4/R5都一样,分别为12/23/34/45网段,并且一个环回

二、配置igpR2/R3/R4均属AS2,并且运行eigrp协议

R2(config)#router eigrp  88

R2(config-router)#no auto-summary

R2(config-router)#network  2.2.2.0

R2(config-router)#network  23.1.1.0

测试一下

R2#ping 4.4.4.4

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/100/172 ms

三、

1、配置R1/R2EBGP环境,用其物理接口,(直连BGP

R1(config)#router bgp 1

R1(config-router)#bgp router-id   1.1.1.1(此路由器在BGP 中的身份)

R1(config-router)#neighbor 12.1.1.2 remote-as  2

R2(config)#router bgp 2

R2(config-router)#bgp  router-id  2.2.2.2

R2(config-router)#neighbor  12.1.1.1 remote-as  1

R2(config-router)#

*Nov 21 21:39:33.559: %BGP-5-ADJCHANGE: neighbor 12.1.1.1 Up

 邻居关系建立,发送了open报文

R2#show ip bgp summary 

BGP router identifier 2.2.2.2, local AS number 2

BGP table version is 1, main routing table version 1

 

R2#show ip bgp summary

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

12.1.1.1        4            1       7       7        1    0    0 00:03:19        0

 

2、同样,将R4/R5配置为非直连邻居

R5(config)#ip route 4.4.4.0 255.255.255.0 serial 1/0

R4(config)#ip route 5.5.5.0 255.255.255.0 serial  1/1

配静态时接口必须为本路由器的出接口

R4#ping 5.5.5.5

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:

!!!!!

四、R2/R3/R4要有IGP 环境,

R2(config)#router bgp 2

R2(config-router)#bgp  router-id  2.2.2.2

R2(config-router)#neighbor  3.3.3.3 remote-as  2

R2(config-router)#neighbor 3.3.3.3 update-source  loopback  0

R2#show ip bgp summary

BGP router identifier 2.2.2.2, local AS number 2

BGP table version is 1, main routing table version 1

 

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

3.3.3.3         4            2       6       6        1    0    0 00:02:15        0

12.1.1.1        4            1      60      59        1    0    0 00:51:05        0

R2#

R3#show ip bgp su

R3#show ip bgp summary

BGP router identifier 3.3.3.3, local AS number 2

BGP table version is 1, main routing table version 1

 

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

2.2.2.2         4            2       6       6        1    0    0 00:02:37        0

4.4.4.4         4            2       5       3        1    0    0 00:01:04        0

五、配置BGP 的邻居

R1(config)#router bgp 1

R1(config-router)#network  12.1.1.0 mask  255.255.255.0

R2(config)#router bgp 2

R2(config-router)#network 12.1.1.0 mask  255.255.255.0

R2(config-router)#

1R1/R2有了BGP表,成为BGP邻居

  R2#show bgp

BGP table version is 3, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *>  1.1.1.0/24       12.1.1.1                 0             0 1 i

 *>  2.2.2.0/24       0.0.0.0                  0         32768 i

同样R4/R5也要有bgp邻居关系,

neighbor 5.5.5.5 remote-as 3

 neighbor 5.5.5.5 ebgp-multihop 255

 neighbor 5.5.5.5 update-source Loopback 0

router bgp 3

  bgp router-id 3.3.3.3

neighbor 4.4.4.4 remote-as 2

 neighbor 4.4.4.4 ebgp-multihop 255

 neighbor 4.4.4.4 update-source Loopback0

!        

 

!        

所以完成基本配置后,network,此时邻居关系建立

2IBGP为了防环,有了水平分割,所以要打破水平分割。并且

解决方法:改变路由器的下一跳

R2(config-router)#neighbor  3.3.3.3 next-hop-self

R3(config)#router bgp 2

R3#show ip bgp

BGP table version is 6, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

R3(config-router)#neighbor  4.4.4.4 next-hop-self

R3(config-router)#neighbor   2.2.2.2  next-hop-self

最后全网可通

R5# show bgp

BGP table version is 6, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *>  1.1.1.0/24       4.4.4.4                                0 2 1 i

 *>  2.2.2.0/24       4.4.4.4                                0 2 i

 *>  3.3.3.0/24       4.4.4.4                                0 2 i

 r>  4.4.4.0/24       4.4.4.4                  0             0 2 i

 *>  5.5.5.0/24       0.0.0.0                  0         32768 i

R5#

R1#

R1#show bgp

BGP table version is 6, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *>  1.1.1.0/24       0.0.0.0                  0         32768 i

 *>  2.2.2.0/24       12.1.1.2                 0             0 2 i

 *>  3.3.3.0/24       12.1.1.2                               0 2 i

 *>  4.4.4.0/24       12.1.1.2                               0 2 i

 *>  5.5.5.0/24       12.1.1.2                               0 2 3 i

ping时的注意事项

R1#ping 5.5.5.5

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

R1#ping 5.5.5.5 source  1.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/78/108 ms

猜你喜欢

转载自blog.csdn.net/weixin_43385243/article/details/84453911
今日推荐