Настройка BGP на UBNT

  • Михаил
  • 12 мин. на прочтение
  • 136
  • 12 Dec 2014
  • 12 Dec 2014

R1: Router in AS 1

R2: Router in AS 2

Configuration

Note: These are the IP addresses of the two routers:

R1 IP address: 192.0.2.1

R2 IP address: 203.0.113.1

For the basic configuration of router R1 in AS 1, use the following commands to create a eBGP peer with router R2 in AS 2:

ubnt@R1:~$ configure

[edit]

ubnt@R1# set protocols bgp 1 parameters router-id 192.0.2.1

[edit]

ubnt@R1# set protocols bgp 1 neighbor 203.0.113.1 remote-as 2

[edit]

ubnt@R1# commit

[ protocols bgp 1 ]

Starting routing daemon: bgpd.

[edit]

ubnt@R1# save ; exit

Saving configuration to '/config/config.boot'...

Done

exit

For the basic configuration of router R2 in AS 2, use the following commands to create a eBGP peer with router R1 in AS 1:

ubnt@R2:~$ configure                                                           

[edit]                                                                                                                                            

ubnt@R2# set protocols bgp 2 parameters router-id 203.0.113.1                  

[edit]                                                                         

ubnt@R2# set protocols bgp 2 neighbor 192.0.2.1 remote-as 1                    

[edit]                                                                         

ubnt@R2# commit                                                                

[ protocols bgp 2 ]                                                            

Starting routing daemon: bgpd.                                                 

[edit]                                                                         

ubnt@R2# save; exit                                                            

Saving configuration to '/config/config.boot'...                               

Done                                                                           

exit                                                                           

ubnt@R2:~$

Peer Verification

Use the show ip bgp neighbors command to verify that the peer is established.

ubnt@R1:~$ show ip bgp neighbors

BGP neighbor is 203.0.113.1, remote AS 2, local AS 1, external link

   BGP version 4, remote router ID 203.0.113.1

   BGP state = Established, up for 00:00:13

   Last read 00:55:04, hold time is 180, keepalive interval is 60 seconds

   Neighbor capabilities:

     4 Byte AS: advertised and received

     Route refresh: advertised and received(old & new)

     Address family IPv4 Unicast: advertised and received

   Message statistics:

     Inq depth is 0

     Outq depth is 0

                          Sent       Rcvd

     Opens:                  7          1

     Notifications:          0          0

     Updates:                0          0

     Keepalives:             2          1

     Route Refresh:          0          0

     Capability:             0          0

     Total:                  9          2

   Minimum time between advertisement runs is 30 seconds

   Update source is 192.0.2.1

 

   For address family: IPv4 Unicast

   Community attribute sent to this neighbor(both)

   0 accepted prefixes

 

   Connections established 1; dropped 0

   Last reset never

Local host: 192.0.2.1, Local port: 60047

Foreign host: 203.0.113.1, Foreign port: 179

 Nexthop: 192.0.2.1

 Nexthop global: fe80::de9f:dbff:fe29:5f7

 Nexthop local: ::

BGP connection: non shared network

Read thread: on  Write thread: off

Learned Routes

The show command checks R1 for learned routes, and the configuration commands redistribute static routes on R2, so R1 will learn routes from R2.

Use the show ip route bgp command to check R1 for bgp routes learned from peer R2.

ubnt@R1:~$ show ip route bgp 

ubnt@R1:~$

No routes have been received because no routes have been redistributed. On R2, use the following commands to redistribute the static routes:

ubnt@R2:~$ configure                                                           

[edit]                                                                         

ubnt@R2# set protocols bgp 2 redistribute static                               

[edit]                                                                         

ubnt@R2# commit                                                                 

[edit]                                                                         

ubnt@R2# save; exit                                                            

Saving configuration to '/config/config.boot'...                               

Done                                                                           

exit

Check R1 again for bgp routes learned from peer R2.

ubnt@R1:~$ show ip route bgp 

Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,

       I - ISIS, B - BGP, > - selected route, * - FIB route

 

B>* 0.0.0.0/0 [20/0] via 203.0.113.1, eth2, 00:00:03

B>* 1.0.0.0/24 [20/0] via 203.0.113.1, eth2, 00:00:03

Full Internet Routes

Note: Receiving a full Internet routing table will consume significant amounts of memory; therefore, we do NOT recommend that you use BGP for full routes on the EdgeRouter Lite which only has 512MB of RAM.

Use the show ip route summary command to view the route summary.

admin@ubnt-bgp-test:~$ show ip route summary 

Route Source         Routes               FIB                 

connected            3                    3                   

static               3                    2                    

ebgp                 405543               405541              

ibgp                 0                    0                   

------

Totals               405549               405546