BGP/Examples/Example 1:One router with two peers

From ImageStream Router Documentation

(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
|                  |        |                      |
|                  |        |                      |
| ISP 1            |        |  ISP 2              |
| ISP 1            |        |  ISP 2              |
-
| AS  64513        |        |  AS  64514          |
+
| AS  64513        |        |  AS  514            |
| IP  172.16.96.76 |        |  IP  10.200.10.3    |
| IP  172.16.96.76 |        |  IP  10.200.10.3    |
|                  |        |                      |
|                  |        |                      |
Line 50: Line 50:
The completed file for our example should look like this:
The completed file for our example should look like this:
<pre>
<pre>
-
#********************************************************************#
+
!
-
# Section 1                                                          #
+
# This ASN is for testing and internal use *ONLY*
-
# BGP Configuration                                                  #
+
router bgp 64512
-
#********************************************************************#
+
bgp router-id 192.168.10.5
 +
bgp log-neighbor-changes
 +
network 192.168.10.0/24
-
# Set this to your AS number.
+
# Begin configuration for ISP 1
-
autonomoussystem 9009;
+
neighbor 172.16.96.76 remote-as 64513
 +
neighbor 172.16.96.76 soft-reconfiguration inbound
 +
neighbor 172.16.96.76 description ISP 1
 +
neighbor 172.16.96.76 route-map rm_peer_1_in in
 +
neighbor 172.16.96.76 route-map rm_peer_1_out out
-
bgp yes {
+
# Begin configuration for ISP 2
-
  preference 70;
+
neighbor 10.200.10.3 remote-as 514
 +
neighbor 10.200.10.3 soft-reconfiguration inbound
 +
neighbor 10.200.10.3 description ISP 2
 +
neighbor 10.200.10.3 route-map rm_peer_2_in in
 +
neighbor 10.200.10.3 route-map rm_peer_2_out out
 +
!
-
# Configuration for the bgp peers. Change the peer AS number to
+
ip prefix-list pl_peer_1_out seq 5 permit 192.168.10.0/24
-
# match your peer's AS number. Change the peer IP address to match
+
-
# your peer's IP address.
+
-
# If you have more than one peer, uncomment the second group type
+
-
# section.
+
-
  group type External peeras 9966
+
ip prefix-list pl_peer_2_out seq 5 permit 192.168.10.0/24
-
  {
+
!
-
        peer 172.16.96.76;
+
route-map rm_peer_1_out permit 5
-
  };
+
match ip address prefix-list pl_peer_1_out
-
  group type External peeras 8855
+
set as-path prepend 64512
-
  {
+
!
-
        peer 10.200.10.3;
+
route-map rm_peer_1_in permit 5
-
  };
+
# Adjust this to favor some peers over others.
-
  group type Internal peeras 9009
+
#  Higher number is more preferred
-
  {
+
#  0 - 255 with 100 being the default
-
        peer 192.168.10.3;
+
set local-preference 100
-
        peer 192.168.10.6;
+
!
-
  };
+
route-map rm_peer_2_out permit 5
-
};
+
match ip address prefix-list pl_peer_2_out
 +
set as-path prepend 64512
 +
!
 +
route-map rm_peer_2_in permit 5
 +
# Adjust this to favor some peers over others.
 +
  #  Higher number is more preferred
 +
#  0 - 255 with 100 being the default
 +
set local-preference 100
 +
!
</pre>
</pre>

Revision as of 19:40, 29 May 2008

This is meant to be an example, and not a complete BGP (Border Gateway Protocol) routing configuration.

Scenario

You have two connections to the internet. One connection through ISP 1, one connection through ISP 2. You need to advertise your network of 192.168.10.0/24 to both ISPs, and accept full feeds from both of them. The router has two ethernet interfaces, one connected to a LAN used by your servers, the other connected to a network used by your customers or employees.

Network Diagram

--------------------        -------------------------
|                  |        |                       |
| ISP 1            |        |   ISP 2               |
| AS  64513        |        |   AS  514             |
| IP  172.16.96.76 |        |   IP  10.200.10.3     |
|                  |        |                       |
--------------------        ------------------------
      |                          |
 EBGP |   +----------------------+    
      |   |      EBGP       
      |   |              
---------------------------------------------------------
      |   |     AS 64512
+--------------+               +-------------------+
| Main Router  |               | LAN               |
| 192.168.10.5 |---------------| 192.168.10.129/25 |
+--------------+  Ethernet 1   +-------------------+
      |                                 
      | Ethernet 0      
      |                
+-----------------+                      
| Servers         |
| 192.168.10.1/25 |          
+-----------------+          

Ensure that all routers running BGP have at least 256 MB of memory. Remember to save your configurations to flash whenever you are finished configuring your dynamic routing setup! To enable BGP, do the following:

  1. At the Login: prompt, enter root.
  2. At the Password: prompt, enter your password.
  3. Choose Option 1 (Configuration and Update Menu) from the Main Menu. Select Option 3 (Service Configuration).
  4. From the Service Configuration menu, you can see the status of the Dynamic routing (gated) package. If gated is running, the option will show "(running)".
  5. To start gated, choose Option 3 (Dynamic routing) and choose Option 5 (Start gated) from the Dynamic routing menu. You will also want to select Option 3 (Enable gated on boot) to ensure that BGP session will be established at boottime. Ensure that you have configured gated prior to attempting to start it. Unless it is properly configured, gated will not start.

In our example above, we will be configuring the "Main Router". From the Dynamic routing menu, choose Option 1 (gated configuration). Our AS for this example will be 9009. Choose Option 4 (Configure BGP) from the menu. This will open a file in your default editor.

  1. Edit the "autonomoussystem" parameter. In this case, our AS number is 9009:
  2. Edit the first "External peeras" section
  3. Add additional sections for each external and internal peer

The completed file for our example should look like this:

!
# This ASN is for testing and internal use *ONLY*
router bgp 64512
 bgp router-id 192.168.10.5
 bgp log-neighbor-changes
 network 192.168.10.0/24

 # Begin configuration for ISP 1
 neighbor 172.16.96.76 remote-as 64513
 neighbor 172.16.96.76 soft-reconfiguration inbound
 neighbor 172.16.96.76 description ISP 1
 neighbor 172.16.96.76 route-map rm_peer_1_in in
 neighbor 172.16.96.76 route-map rm_peer_1_out out

 # Begin configuration for ISP 2
 neighbor 10.200.10.3 remote-as 514
 neighbor 10.200.10.3 soft-reconfiguration inbound
 neighbor 10.200.10.3 description ISP 2
 neighbor 10.200.10.3 route-map rm_peer_2_in in
 neighbor 10.200.10.3 route-map rm_peer_2_out out
!

ip prefix-list pl_peer_1_out seq 5 permit 192.168.10.0/24

ip prefix-list pl_peer_2_out seq 5 permit 192.168.10.0/24
!
route-map rm_peer_1_out permit 5
 match ip address prefix-list pl_peer_1_out
 set as-path prepend 64512 
!
route-map rm_peer_1_in permit 5
 # Adjust this to favor some peers over others.
 #  Higher number is more preferred
 #  0 - 255 with 100 being the default
 set local-preference 100
!
route-map rm_peer_2_out permit 5
 match ip address prefix-list pl_peer_2_out
 set as-path prepend 64512 
!
route-map rm_peer_2_in permit 5
 # Adjust this to favor some peers over others.
 #  Higher number is more preferred
 #  0 - 255 with 100 being the default
 set local-preference 100
!

Next, we will need to configure the main gated configuration file. Choose Option 1 (Configure gated) from the gated configuration menu. This will open a file in your default editor.

  1. In Section 1 - Global Configuration, configure the "routerid" parameter. Set this IP address to the primary IP address used on Ethernet0 on the router. In this case, the IP address is 192.168.10.5.
  2. In Section 2 - Routing Protocol Configuration, uncomment the %include "/etc/gated.bgp" line to enable BGP within gated.
  3. In Section 3 - Static Routes, add all static routes defined in wan.conf, regardless of whether or not you export them. The "retain" keyword you see in the default configuration file tells gated not to remove this route if gated exits. For the purposes of this example, we have set a default gateway of 172.16.96.75, which would point to the serial interface on Router 1.
  4. In Section 4 - Exporting Routes, edit the default section and add a section for each external peer. Add one section for all internal peers.
  5. In Section 5 - Importing Routes, edit the default section and add a section for each external peer. Add one section for all internal peers.

The completed file for our example should look like this:

#********************************************************************#
# Section 1                                                          #
# Global Configuration                                               #
#********************************************************************#

# Uncomment (remove the # sign) and set routerid to your main ethernet
# IP address

routerid 192.168.10.5 ;

#********************************************************************#
# Section 2                                                          #
# Routing Protocol Configuration                                     #
#********************************************************************#

# Uncomment the routing protocols you want to use
%include "/etc/gated.bgp"
#%include "/etc/gated.ospf"
#%include "/etc/gated.rip"

#********************************************************************#
# Section 3                                                          #
# Static routes                                                      #
#********************************************************************#

# Add any static routes that you need in the routing table. 
# Retain tells gated not to remove this route if gated
# exits.

static
{
# Set the default gateway to 172.16.96.76.
        0.0.0.0 mask 0.0.0.0 gateway 172.16.96.76 retain;
# Set a static route to the 192.168.1.0/24 network.
        192.168.2.0 mask 255.255.255.0 gateway 192.168.10.18 retain;
};

#********************************************************************#
# Section 4                                                          #
# Exporting routes                                                   #
#********************************************************************#

#--------------------------------------------------------------------#
# OSPF Export
# This Export proto statement will export static routes and interface
# routes via OSPF

export proto ospfase {
   proto static {
      ALL
        metric 1;   };
   proto direct {
      ALL
        metric 1;   };
};

#--------------------------------------------------------------------#
# BGP Export
# These Export proto statements will export:
#    the static route 192.168.2.0/24
#    the interface route 192.168.10.0/24
# to AS numbers 9966, 8855 and 9009 via BGP.

export proto bgp as 9966 {
   proto static {
      192.168.2.0 masklen 24 exact;
   };
   proto direct {
      192.168.10.0 masklen 24 exact;
   };
};

export proto bgp as 8855 {
   proto static {
      192.168.2.0 masklen 24 exact;
   };
   proto direct {
      192.168.10.0 masklen 24 exact;
   };
};

export proto bgp as 9009 {
   proto static {
      192.168.2.0 masklen 24 exact;
   };
   proto direct {
      192.168.10.0 masklen 24 exact;
   };
};

#--------------------------------------------------------------------#
# RIP Export
# This Export proto statement will export static routes and interface
# routes via RIP

export proto rip {
   proto static {
      ALL
        metric 1;   };
   proto direct {
      ALL
        metric 1;   };
};

#********************************************************************#
# Section 5                                                          #
# Importing routes                                                   #
#********************************************************************#

#--------------------------------------------------------------------#
# OSPF Import
# This import statement will import all routes learned via OSPF.

import proto ospfase {
        ALL;
};

#--------------------------------------------------------------------#
# BGP Import
# This import statements will import all routes from AS numbersi 9966, 
# 8855 and 9009 learned via BGP.

import proto bgp as 9966 {
        ALL;
};
import proto bgp as 8855 {
        ALL;
};
import proto bgp as 9009 {
        ALL;
};

#--------------------------------------------------------------------#
# RIP Import
# This import statement will import all routes learned via RIP.

import proto rip {
        ALL;
};

Remember to save your configurations to flash whenever you are finished configuring your dynamic routing setup!

Personal tools
Router software releases