Friday, May 22, 2015

CCIE OCG: Classification and Marking

IP Precedence and DSCP Compared

  • IP header includes a 1-byte Type of Service (ToS) field.
  • The ToS was intended to be used to mark a packet for treatment with QoS tools.
  • The ToS field is further divided: the high-order 3 bits defined as IP Precedence (IPP).
  • Bits 3 through 6 of the ToS byte included flag fields which were not used very often.
  • Along came Differentiated Services (DiffServ).
  • DiffServ needed more than 3 bits to mark packets, so it redefined the ToS byte.
  • The ToS was renamed Differentiated Services (DS) field, and IPP was replaced with a 6-bit field called Differentiated Services Code Point (DSCP).
  • The low-order 2 bits is used with QoS Explicit Congestion Notification (ECN).
 
IP Precendence Values
Name Decimal Value Binary Value
Routine Precedence 0 000
Priority Precedence 1 001
Immediate Precedence 2 010
Flash Precedence 3 011
Flash Override Precedence 4 100
Critical Precedence 5 101
Internetwork Control Precedence 6 110
Network Control Precedence 7 111


DSCP Settings and Terminology

  • For example, DSCP 46 is Expedited Forwarding (EF). 
  • EF should be given queuing preference for minimal latency but the packets should be prevented from congesting the link.
  • The suggested settings and associated QoS behavior are called Per-Hop Behaviors (PHB). 
  • IPP and DSCP overlap.
  • Class Selector (CS) PHB provide backward compatibility between DSCP and IPP. 
  • IPP can still understand DSCP values.
  • Packets with larger CS DSCPs should be given better queuing preference than packets with lower CS DSCPs.


Default and Class Selector DSCP Values

DSCP Class Selector  Binary DSCP Value IPP Value IPP Names
Default/CS0 00000000 000 Routine
CS1 00100000 001 Priority
CS2 01000000 010 Immediate
CS3 01100000 011 Flash
CS4 10000000 100 Flash Override
CS5 10100000 101 Critical
CS6 11000000 110 Internetwork Control
CS7 11100000 111 Network Control


  • The Assured Forwarding (AF) defines four classes for queuing purposes and three levels of drop probability inside each queue.
  • AF conforms to the following format:
  1. AFxy, where x implies one of the queues (1-4) and y implies one the three drop priorities (1-3).
  2. The higher the x, the better queuing treatment a packet should get.
  3. The higher the y, the worse the drop treatment for those packets (more likely to get dropped).
  • For example, AF11 should get worse queuing treatment than AF23. However, AF11 has better drop treatment than AF23.


Assured Forwarding DSCP Values

Queue Class  Low Drop Probability Medium Drop Probability High Drop Probability

Name/Decimal/Binary Name/Decimal/Binary Name/Decimal/Binary
1 AF11/10/001010 AF12/12/001100 AF13/14/001110
2 AF21/18/010010 AF22/20/010100 AF23/22/010110
3 AF31/26/011010 AF32/28/011100 AF33/30/011110
4 AF41/34/100010 AF42/36/100100 AF43/38/100110


  • Conversion Formula: If AFxy, then 8x-2y.
  • Example: AF41 = 8*4+2*1 = 34.
  • Expedited Forwarding (EF):
  1. Queue EF packets so that they get scheduled quickly, to give them low latency.
  2. Police the EF packets so that they do not consume all bandwidth on the link or starve other queues. 
  • IP packets get encapsulated inside other headers, which have their own QoS fields.

 

Ethernet LAN Class of Service (CoS)

  • Ethernet supports a 3-bit QoS marking field but it only exists when the Ethernet header includes either a 802.1Q or ISL header.
  • 802.1Q: the 3 most significant bits of the 2-byte Tag Control field (user-priority bits).
  • ISL: the 3 least significant bits from the 1-byte User field. 
  • Frame Relay and ATM have a single bit to define drop probability: Discard Eligibility (DE) and Cell Loss Priority (CLP), respectively.
  • MPLS defines a 3-bit field called the MPLS Experimental (EXP) bit that is intended for general QoS marking.

 

Location for Marking and Matching

  • For classification: On ingress only, and only if the interface supports that particular header field.
  • For marking: On egress only, and only if the interface supports that particular header field.

Marking Field Summary
Field Location Length
IP Precedence IP Header 3 bits
IP DSCP IP Header 6 bits
DS field IP Header 1 byte
ToS byte IP Header 1 byte
CoS ISL and 802.1Q header 3 bits
Discard Eligibel (DE) Frame Relay header 1 bit
Cell Loss Priority (CLP) ATM cell header 1 bit
MPLS Experimental MPLS header 3 bits



Cisco Modular QoS CLI

  • Intended to simply QoS configuration. 
  • MQC-based tools all begin with the phrase "class-based".
  • Three major commands:
    1. The class-map command defines the matching parameters for classifying packets into service classes.
    2. The PHB actions (marking, queuing, and so on) are configured under a policy-map command.
    3. The policy-map is enabled on an interface by using a service-policy command. 
  • Packets are classified using the match command inside the class-map. 
  • The match command has many options for matching packets, including QoS fields, ACLs, and MAC addresses. 
  • Class-map names are case-sensitive. 
  • The match protocol commands means that IOS uses NBAR to perform that match. 
  • The match any command matches any and all packets. 
  • CEF is required for class-based marking. Without it, the class-map and policy-map configuration would be allowed, but the service-policy command would be rejected. 
  • Class-maps can use multiple match commands, and even nest class-maps inside other class-maps.
  • Up to four (CoS and IPP) or eight (DSCP) values can be listed on a single match cos, match precedence, or match dscp command. If any is found in the packet, the statement is matched.
  • If the class-map has multiple match commands, the match-any or match-all (default) defines whether a logical OR or a logical AND is used, respectively.
  • The match class command refers to another class-map by name, nesting the logic. It is considered a match if the referenced class-map also results in a match.

! This class-map matches packets that are permitted by ACL 101 and have an IPP of 5.
class-map match-all EXAMPLE-A
 match access-group 101
 match precedence 5


! This class-map matches packets that are permitted by ACL 101 or have a DSCP of AF21.
class-map match-any EXAMPLE-B
 match access-group 101
 match dscp AF21


! This class-map will never match anything because a packet cannot have two DSCP values.
class-map match-all EXAMPLE-C
 match dscp 0
 match dscp 1


! This example shows the use of nested class-maps.
class-map match-all CHILD-CLASS
 match access-group 101
 match precedence 5
!
class-map match-any PARENT-CLASS
 match class CHILD-CLASS
 match cos 5


Mach: Packets permitted by ACL 101 AND marked with IPP 5 OR frames with CoS 5.


Classification Using NBAR

  • NBAR classifies packets that are normally difficult to classify.
  • Some applications use dynamic port numbers, so static match command will not work.
  • NBAR can do deep packet inspection, looking at the host name, URL, MIME, and so on.
  • NBAR can look past the TCP and UDP headers to recognize application-specific information.

 

Configuration

  • CB marking requires CEF.
  • Packets are classified based on the logic in MQC class-maps.
  • An MQC policy-map refers to one or more class-maps; packets classified into that class are then marked.
  • CB marking is enabled in either ingress or egress direction.
  • A policy-map is processed sequentially; after a packet has matched a class, it is marked based on the set command(s) defined for that class.
  • Multiple set commands can be configured in one class to set multiple fields, for example to set both DSCP and CoS.
  • Packets that do not explicitly match a defined class are considered to have matched a special class called class-default.
  • For any class inside the policy-map for which there is no set command, packets in that class are not marked.

 Example:
  • Frames entering with CoS 5 will be marked with DSCP EF.
  • Frames entering with CoS 1 will be marked with DSCP AF11.
  • Frames entering with any other CoS will be marked with DSCP 0.
  • Packets exiting with DSCP EF will be marked with CoS 5.
  • Packets exiting with DSCP AF11 will be marked with CoS 1.
  • Packets exiting with any other DSCP will be marked with CoS 0.

class-map COS1
 match cos 1
!
class-map COS5
 match cos 5
!
class-map AF11
 match dscp af11
!
class-map EF
 match dscp EF
!
policy-map COS-TO-DSCP-IN
 class COS1
  set dscp af11
 class COS5
   set dscp ef
 class class-default
  set ip dscp default
!
policy-map DSCP-TO-COS-OUT
 class AF11
  set cos 1
 class EF
  set cos 5
 class class-default
  set cos 0
!
interface FastEthernet0/0.10
 encapsulation dot1q 10
 service-policy input COS-TO-DSCP-IN
 service-policy output DSCP-TO-COS-OUT


Only interfaces configured for 802.1Q accept service-policy commands that reference policy-maps that either classify or mark based on CoS.


CB Marking Design Choices

  • Packets should generally be marked as close to the ingress point of the packet as possible. 
  • However, the earliest point might not be a trusted device.
  • Rule: "Mark as close to the ingress edge of the network as possible, but not so close to the edge that the marking is made by an untrusted device." 
  • Cisco recommends not to use more than four or five different service classes for data traffic.


Recommended Values For Marking

Type of Traffic CoS IPP DSCP
Voice Payload 5 5 EF
Video Payload 4 4 AF41
Voice/Video Signaling 3 3 CS3
Mission-Critical Data 3 3 AF31, AF32, AF33
Transactional Data 2 2 AF21, AF22, AF23
Bulk Data 1 1 AF11, AF12, AF13
Best Effort 0 0 BE
Scavenger 0 0 2, 4, 6


Marking Using Policers

  • Traffic policers measure entering/exiting an interface -determining whether a configured traffic contract has been exceeded.
  • Two components: a traffic rate (bits/second), and a burst size (bytes).
  • Traffic within the limits is conformed to the contract.
  • Traffic over the rate or burst is exceeding the contract.
  • The simplest form of policing discards packets that exceeded the contract.
  • Another option: mark down packets instead of dropping them.
  • Example: a policer could re-mark AF11 packets that exceeded the contract with a new DSCP value of AF13, but not discard the packet.

QoS Pre-Classification

  • When packets are tunneled or encrypted, the original headers and packet contents are unavailable for inspection.
  • QoS pre-classification allows a VPN endpoint router to make egress QoS decisions based on the original traffic, before encapsulation.


AutoQoS

  • A macro that helps automate class-based QoS configuration.
  • It creates and applies QoS configurations based on Cisco best practice recommendations.
  • Two flavors: AutoQoS for VoIP and AutoQoS for the Enterprise.

AutoQoS for VoIP

  • Automatic QoS configuration for voice and video applications.
  • Assumes two types of ports on switches: user access and uplink.
  • Also assumes that a user access port might or might not have an IP phone.
  • When enabled for any interface, the command starts a macro that globally enables QoS, configures interface ingress and egress queues, configures class-maps and policy-maps, and applies the policy-map to the interface.
  • Enabled with the interface-level command auto qos [cisco-phone | cisco-softphone].
  • If no phone is found, all traffic is marked down to DSCP 0 and treated as best effort.
  • If a phone is found, the received QoS markings are trusted.
  • Voice and video control traffic, real-time video traffic, voice traffic, routing protocol traffic, and STP BPDU traffic has priority (expedited forwarding).
  • Uplink ports use the auto qos voip trust command.

AutoQoS for the Enterprise

  • Automates the QoS configuration for VoIP and other network applications.
  • Meant to be used for WAN links.
  • It detects the types and amounts of network traffic and then creates policies based on that.
  • Two steps:
  1. Discover the traffic.
  2. Provide recommended QoS configuration.
  • Enable discovery: auto discovery qos [trust].
  • Make sure CEF is enabled, the interface bandwidth is configured, and no QoS configuration is applied.
  • Use the trust keyword to trust received markings.
  • Traffic discovery uses NBAR to learn the types and amounts of traffic on each enabled interface.
  • After traffic discovery has collected enough information, run auto qos on the interface.
  • This runs a macro that creates templates based on the traffic collected, creates class-maps to classify traffic, and creates a policy-map to allocate bandwidth and mark the traffic.

Monday, May 11, 2015

400-101: BGP, Part VI:II

3.7e Implement and Troubleshoot Scalability


3.7e(ii) Confederations

BGP confederations introduce the concept of creating a number of smaller autonomous systems within an original autonomous system. The sub-ASs exchange BGP update between them using intra-confederation eBGP sessions.

With BGP confederations, member-ASs are never visible from outside the confederation. This allows private AS numbers (64512 to 65535) to be used inside the confederation. BGP routers inside the member-AS must still maintain a full mesh of iBGP sessions. EBGP sessions are established between member-ASs. These eBGP sessions behave slightly differently from classic or real eBGP sessions (referred to as intra-confederation eBGP sessions to differentiate them from true eBGP sessions).

When a router sends a BGP update over an intra-confederation eBGP session, it prepends the member-AS number to the AS_PATH attribute. This information is maintained by the routers within the confederation. When a router sends a BGP update over a true eBGP session, it removes the part of the AS_PATH that describes the member-AS numbers and prepends the official AS number to the AS_PATH. As a result, the confederation appears as one single AS to the outside world.

When a router sends an update over an intra-confederation eBGP, it prepends the member-AS number in parenthesis. Routers do not modify the AS_PATH when transmitting over an iBGP session. When advertising the route to a true eBGP peer, the router removes the parenthesized information and replaces it with the official AS number of the confederation.

All else being equal, the BGP best path decision process chooses normal eBGP routes over confederation eBGP over iBGP routes.

A router that does not support BGP confederations cannot operate inside a BGP confederation. A router not supporting BGP confederations will reject an AS_PATH with unknown segement type.

Although intra-confederation eBGP sessions have eBGP-like properties, they still run inside a real AS and therefore share some properties with iBGP sessions to achieve the same results. Similar to iBGP, the BGP attributes of local preference, MED, and next-hop are not changed across intra-confederation eBGP sessions. All routers in all member-ASs inside the confederation consequently see the same next-hop address when doing recursive routing. The entire confederation should then use the same IGP to resolve the BGP next-hop address.

As a summary, the route reflectors modify the BGP split horizon rule and confederations modify AS_PATH processing. Intra-confederation eBGP sessions act like eBGP sessions from a session establishment perspective, and they act like iBGP sessions from the BGP attribute-propagation perspective.

 

Configuration Example


The confederation AS 12 is divided into two sub-AS 65001 and 65002. Routers inside each sub-AS are configured with full-mesh BGP peering. Each router uses 150.1.x.x/32 as its router-ID and advertises a Loopback network (as depicted in the topology diagram). Peer groups are used to cut down on the configuration. OSPF is enabled for full IP connectivity inside the confederation.

R1#
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 bgp confederation identifier 12
 bgp confederation peers 65002
 network 1.1.1.0 mask 255.255.255.0
 neighbor CONFED-PEER peer-group
 neighbor CONFED-PEER remote-as 65001
 neighbor CONFED-PEER update-source Loopback0
 neighbor 10.1.17.7 remote-as 78
 neighbor 10.1.18.8 remote-as 78
 neighbor 150.1.2.2 remote-as 65002
 neighbor 150.1.2.2 ebgp-multihop 2
 neighbor 150.1.2.2 update-source Loopback0
 neighbor 150.1.3.3 peer-group CONFED-PEER
 neighbor 150.1.4.4 peer-group CONFED-PEER
 no auto-summary


 R2#
router bgp 65002
 no synchronization
 bgp log-neighbor-changes
 bgp confederation identifier 12
 bgp confederation peers 65001
 network 2.2.2.0 mask 255.255.255.0
 neighbor CONFED-PEER peer-group
 neighbor CONFED-PEER remote-as 65002
 neighbor CONFED-PEER update-source Loopback0
 neighbor 150.1.1.1 remote-as 65001
 neighbor 150.1.1.1 ebgp-multihop 2
 neighbor 150.1.1.1 update-source Loopback0
 neighbor 150.1.5.5 peer-group CONFED-PEER
 neighbor 150.1.6.6 peer-group CONFED-PEER
 no auto-summary


 R8#
router bgp 78
 no synchronization
 bgp log-neighbor-changes
 network 8.8.8.0 mask 255.255.255.0
 neighbor 10.1.18.1 remote-as 12
 no auto-summary



Let's see what the routers (R5) inside the sub-AS are learning.

R5#show ip bgp
BGP table version is 9, local router ID is 150.1.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       150.1.1.1                0    100      0 (65001) i
*>i2.2.2.0/24       150.1.2.2                0    100      0 i
*>i3.3.3.0/24       150.1.3.3                0    100      0 (65001) i
*>i4.4.4.0/24       150.1.4.4                0    100      0 (65001) i
*> 5.5.5.0/24       0.0.0.0                  0         32768 i
*>i6.6.6.0/24       150.1.6.6                0    100      0 i
*>i7.7.7.0/24       10.1.17.7                0    100      0 (65001) 78 i
*>i8.8.8.0/24       10.1.18.8                0    100      0 (65001) 78 i



Note that the next-hop and local preference values are retained across confederation-EBGP peering (example route 8.8.8.0/24 from R8). The AS number inside the parenthesis signifies that the route has traversed through a confederation sub-AS.

R5#show ip bgp 8.8.8.0/24
BGP routing table entry for 8.8.8.0/24, version 9
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  (65001) 78
    10.1.18.8 (metric 30) from 150.1.2.2 (150.1.2.2)
      Origin IGP, metric 0, localpref 100, valid, confed-internal, best



According to BGP confederation rules, true eBGP peers should not see the sub-AS numbers. They don't. From R8's perspective, the routes originated from AS 12.

R8#show ip bgp
BGP table version is 8, local router ID is 150.1.8.8
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       10.1.18.1                0             0 12 i
*> 2.2.2.0/24       10.1.18.1                              0 12 i
*> 3.3.3.0/24       10.1.18.1                              0 12 i
*> 4.4.4.0/24       10.1.18.1                              0 12 i
*> 5.5.5.0/24       10.1.18.1                              0 12 i
*> 6.6.6.0/24       10.1.18.1                              0 12 i
*> 8.8.8.0/24       0.0.0.0                  0         32768 i

Sunday, May 10, 2015

400-101: BGP, Part VI:I

3.7e Implement and Troubleshoot Scalability


The iBGP full-mesh requirement (BGP split-horizon rule) does not scale well when there is a large number of iBGP speakers. For n iBGP speakers, n(n-1)/2 sessions must be maintained. Two methods have been developed to solve this scaling problem: BGP route reflectors and BGP confederations.

3.7e(i) Route Reflector, Cluster

Route reflectors enable routing information to be redistributed to all routers within an AS while eliminating the need for a fully meshed topology. Route reflectors reduce the number of TCP sessions that must be maintained - lowering network overhead, and also CPU and memory resource requirements. BGP route reflectors operate similarly to OSPF DR/BDR or IS-IS DIS.

In a route-reflector-based iBGP network, BGP routers are divided into route reflectors (implement modified BGP split horizon rules) and clients (behave like traditional iBGP routers). A client has only one iBGP connection - to the route reflector. Further, the route reflector breaks the BGP split horizon rule. When an iBGP update is received from a client, the route reflector forwards the update to other iBGP neighbors - alleviating the iBGP full-mesh requirement for the clients. Similarly, when the route reflector receives an update from a non-client, it forwards the update to all of its clients. Any of the common BGP attributes are not changed.

IBGP peers of the route reflector fall under two categories: clients and non-clients. The route reflector and its clients form a cluster. All iBGP peers of the route reflector that are not part of the cluster are non-clients.

Clients may have any number of eBGP peers but may have only one iBGP session with the route reflector(s). One route reflector is a single point of failure. If the route reflector fails, its clients can no longer send BGP updates or receive them from the rest of the AS. Therefore, the route reflector functionality must be redundant (two route reflectors).

Route reflector clusters prevent iBGP routing loops in redundant route reflector designs. A design requirement is to properly identify which route reflectors and their clients form a cluster. A unique cluster-ID (within the AS) must be configured on the route reflectors. A route reflector can reflect routes only within a single cluster. A route reflector can participate in another cluster, but only as a client. A client can function as a client only to a route reflector belonging to the same cluster.

When a route is reflected, the route reflector creates the CLUSTER_LIST attribute and attaches it to the route if it does not already exist. It then sets the cluster-ID in the CLUSTER_LIST or adds its cluster-ID to an already existing CLUSTER_LIST attribute. If the route is ever reflected back to the same reflector, it recognizes its cluster-ID and does not forward the route. The first route reflector that reflects a route also sets an additional BGP attribute, called ORIGINATOR_ID, which carries the BGP router-ID of the iBGP router that sent the route. As a loop prevention mechanism, any router that receives an iBGP update with the ORIGINATOR_ID attribute set to its own BGP router-ID or with its cluster-ID already in the CLUSTER_LIST, ignores that update. Both CLUSTER_LIST and ORIGINATOR_ID are optional non-transitive BGP attributes.

The BGP best path selection process is modified when a router receives both reflected and non-reflected routes. The traditional BGP best path selection parameters - such as WEIGHT, LOCAL_PREF, ORIGIN, and MED - are compared first. If equal, the routes received from eBGP neighbors are preferred over routes received from iBGP neighbors. If reflected and non-reflected (no ORIGINATOR_ID) are available, the non-reflected routes are preferred. Reflected routes with shorter CLUSTER_LISTs are preferred. Finally, if the route-reflector-specific selection criteria does not yield a decision, the rest of the traditional BGP path selection rules are followed.

The route reflection BGP best path selection process as a summary:
  1. Traditional BGP best path parameters (WEIGHT, LOCAL_PREFERENCE, ORIGIN, MED, and so on).
  2. eBGP over iBGP.
  3. Non-reflected routes over reflected routes.
  4. A route with a shorter CLUSTER_LIST is preferred.
  5. The rest of the traditional BGP path selection process. 

NOTE: BGP route reflectors are a control plane mechanism. The route reflectors don't have to, and often do not, exist in the data path between the networks. However, if the route reflectors fail, BGP communication will eventually stop even if the underlying network is up and running.

 

3.7e(i) Configuration Example



RR stands for route reflector. All iBGP routers are configured with Lo0: 150.x.x.x/32, which is used as the source IP address for the BGP sessions. In addition, route reflector clients have Lox: x.x.x.x/24, where x is the number of the router, that is advertised via BGP. OSPF is enabled in AS 12 for full IP connectivity. Finally, RR2 is operating as a route reflector client for RR1.


Including only relevant BGP configuration.

RR1#
router bgp 12
 no synchronization
 bgp router-id 150.1.1.1
 bgp cluster-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor RR-CLIENT peer-group
 neighbor RR-CLIENT remote-as 12
 neighbor RR-CLIENT update-source Loopback0
 neighbor RR-CLIENT route-reflector-client
 neighbor 150.2.2.2 peer-group RR-CLIENT
 neighbor 150.3.3.3 peer-group RR-CLIENT
 neighbor 150.4.4.4 peer-group RR-CLIENT
 no auto-summary


RR2#
router bgp 12
 no synchronization

 bgp router-id 150.2.2.2
 bgp cluster-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor RR-CLIENT peer-group
 neighbor RR-CLIENT remote-as 12
 neighbor RR-CLIENT update-source Loopback0
 neighbor RR-CLIENT route-reflector-client
 neighbor 150.1.1.1 remote-as 12
 neighbor 150.1.1.1 update-source Loopback0
 neighbor 150.5.5.5 peer-group RR-CLIENT
 neighbor 150.6.6.6 peer-group RR-CLIENT
 no auto-summary



A sample configuration for the route reflector clients (R6). The rest of the route reflector clients have identical configuration with the exception of the advertised network or RR1/RR2 neighbor address.

R6#
router bgp 12
 no synchronization
 bgp log-neighbor-changes
 network 6.6.6.0 mask 255.255.255.0
 neighbor 150.2.2.2 remote-as 12
 neighbor 150.2.2.2 update-source Loopback0
 no auto-summary



R3 is also peered with external BGP routers R7 and R8.

R3#
router bgp 12
 no synchronization
 bgp log-neighbor-changes
 network 3.3.3.0 mask 255.255.255.0
 neighbor 10.1.37.7 remote-as 78
 neighbor 10.1.38.8 remote-as 78
 neighbor 150.1.1.1 remote-as 12
 neighbor 150.1.1.1 update-source Loopback0
 no auto-summary



 R6 is learning all Loopback0 networks.

R6#show ip bgp
BGP table version is 7, local router ID is 150.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i3.3.3.0/24       150.3.3.3                0    100      0 i
*>i4.4.4.0/24       150.4.4.4                0    100      0 i
*>i5.5.5.0/24       150.5.5.5                0    100      0 i
*> 6.6.6.0/24       0.0.0.0                  0         32768 i
*>i7.7.7.0/24       10.1.37.7                0    100      0 78 i
*>i8.8.8.0/24       10.1.38.8                0    100      0 78 i



Let's look at a specific route entry for 4.4.4.0/24. Note that the CLUSTER_LIST includes both cluster-IDs through which the update has traversed (2.2.2.2, 1.1.1.1). The router-ID of the iBGP peer from which the route has been received is copied into the ORIGINATOR_ID attribute.

R6#show ip bgp 4.4.4.0/24
BGP routing table entry for 4.4.4.0/24, version 5
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  Local
    150.4.4.4 (metric 31) from 150.2.2.2 (150.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Originator: 150.4.4.4, Cluster list: 2.2.2.2, 1.1.1.1 



For comparison, see the route for 8.8.8.0/24. Pay specific attention to the ORIGINATOR_ID, which is now 150.3.3.3 (R3) - the iBGP peer that advertised the route the route reflector (RR1).

R6#show ip bgp 8.8.8.0/24
BGP routing table entry for 8.8.8.0/24, version 7
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  78
    10.1.38.8 (metric 30) from 150.2.2.2 (150.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Originator: 150.1.3.3, Cluster list: 2.2.2.2, 1.1.1.1



Bonus: The metric is derived from the OSPF route.

R6#show ip route 150.4.4.4
Routing entry for 150.4.4.4/32
  Known via "ospf 1", distance 110, metric 31, type intra area
  Last update from 10.2.56.5 on FastEthernet0/0.56, 00:49:56 ago
  Routing Descriptor Blocks:
  * 10.2.56.5, from 150.4.4.4, 00:49:56 ago, via FastEthernet0/0.56
      Route metric is 31, traffic share count is 1

Saturday, May 9, 2015

400-101: BGP, Part V

3.7f Implement and troubleshoot MP-BGP


3.7f(i) IPv4, IPv6, VPN address-family


BGP has multi-protocol capability. In a single session, BGP can carry multiple routed protocols (IPv4 unicast, IPv4 multicast, IPv6 unicast, IPv6 multicast, VPNv4, and so on). These are called "address families". However, a method is needed to tell BGP which address families should be exchanged with a particular neighbor. Defining a neighbor under a particular address family means that the router wants to exchange routes from the particular address family with the neighbor(s) listed there. Neighbors are automatically added to the "invisible" address-family ipv4 section. Different address families can be exchanged with the same neighbor.

BGP uses capability negotiation to confirm that the peer supports the required address families. These capabilites include different values for AFI and SAFI. Both routers must support a capability to use it. The capability is advertised in Open messages.

The bgp upgrade-cli will convert the BGP configuration to the address family style of configuration. Basic BGP peering settings are configured outside the address family scopes. The per-address-family configuration is naturally moved under the address family itself. BGP operation does not change with this new style of configuration, only the configuration format.

The no bgp default ipv4-unicast command will prevent BGP from automatically assigning each newly defined neighbor into the address-family ipv4 section.


1. address-family ipv4

Example: IBGP configuration between R1 and R2 in AS 100.

R1#
interface Loopback10
 ip address 10.1.1.1 255.255.255.0
!
interface Loopback11
 ip address 11.1.1.1 255.255.255.0
!
interface Loopback12
 ip address 12.1.1.1 255.255.255.0
!
interface Loopback13
 ip address 13.1.1.1 255.255.255.0
!
interface FastEthernet0/0.123
 encapsulation dot1Q 123
 ip address 155.1.123.1 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 10.1.1.0 mask 255.255.255.0
 network 11.1.1.0 mask 255.255.255.0
 network 12.1.1.0 mask 255.255.255.0
 network 13.1.1.0 mask 255.255.255.0
 neighbor 155.1.123.2 remote-as 100
 no auto-summary



Upgrading the CLI.

R1(config-router)#bgp upgrade-cli
You are about to upgrade to the AFI syntax of bgp commands

Are you sure ? [yes]:



After the upgrade, the configuration looks slightly different. The networks are advertised under the address family, and the neighbor is activated there.

R1#
router bgp 100
 bgp log-neighbor-changes
 neighbor 155.1.123.2 remote-as 100
 !
 address-family ipv4
  neighbor 155.1.123.2 activate
  no auto-summary
  no synchronization
  network 10.1.1.0 mask 255.255.255.0
  network 11.1.1.0 mask 255.255.255.0
  network 12.1.1.0 mask 255.255.255.0
  network 13.1.1.0 mask 255.255.255.0
 exit-address-family



2. address-family ipv6

To advertise IPv6 routes, a new address family is simply added.

R1#
interface Loopback6
 no ip address
 ipv6 address 2001:1111::1/64
!
ipv6 unicast-routing
!
router bgp 100
 bgp log-neighbor-changes
 neighbor 155.1.123.2 remote-as 100
 !
 address-family ipv4
  neighbor 155.1.123.2 activate
  no auto-summary
  no synchronization
  network 10.1.1.0 mask 255.255.255.0
  network 11.1.1.0 mask 255.255.255.0
  network 12.1.1.0 mask 255.255.255.0
  network 13.1.1.0 mask 255.255.255.0
 exit-address-family
 !
 address-family ipv6
  neighbor 155.1.123.2 activate
  network 2001:1111::/64
 exit-address-family



R2#
router bgp 100
 bgp log-neighbor-changes
 neighbor 155.1.123.1 remote-as 100
 !
 address-family ipv4
  neighbor 155.1.123.1 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family ipv6
  neighbor 155.1.123.1 activate
 exit-address-family



R2's BGP table for IPv6

R2#show bgp ipv6 unicast
BGP table version is 1, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
* i2001:1111::/64   ::FFFF:155.1.123.1
                                             0    100      0 i



3. address-family vpnv4

The BGP VPNv4 address family is commonly used with MPLS VPNs. Because PE routers can learn the same prefixes from different customers (CEs), a method to uniquely identify each route is needed. This is done with a route distinguisher (RD), which adds a 8-byte value to an IPv4 prefix - creating a VPNv4 prefix. The RD is specified inside the VRF. In addition to the RD, BGP uses a route target (an extended community) to control the import and export of the routes.

The route distinguisher and the route target can have the same value. If the route target values are different for import and export, they need to match on the neighbor accordingly. The value is typically represented in the format AS:NN (as demonstrated below).

R1(config-vrf)#rd ?
  ASN:nn or IP-address:nn  VPN Route Distinguisher



First, the VRFs are configured. Note that CUSTOMER-ONE is using 65000:1 for export and 65000:11 for import (vice versa on R2). CUSTOMER-TWO is using 65000:2 for both.

R1#
ip vrf CUSTOMER-ONE
 rd 65000:1
 route-target export 65000:1
 route-target import 65000:11
!
ip vrf CUSTOMER-TWO
 rd 65000:2
 route-target both 65000:2
!
interface Loopback1
 ip vrf forwarding CUSTOMER-ONE
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback2
 ip vrf forwarding CUSTOMER-TWO
 ip address 2.2.2.2 255.255.255.0



R2#
ip vrf CLIENT-ONE
 rd 65000:1
 route-target export 65000:11
 route-target import 65000:1
!
ip vrf CLIENT-TWO
 rd 65000:2
 route-target export 65000:2
 route-target import 65000:2
!
interface Loopback11
 ip vrf forwarding CLIENT-ONE
 ip address 11.11.11.11 255.255.255.0
!
interface Loopback22
 ip vrf forwarding CLIENT-TWO
 ip address 22.22.22.22 255.255.255.0



VRF verification on R1.

R1#show ip vrf brief
  Name                             Default RD          Interfaces
  CUSTOMER-ONE                     65000:1             Lo1
  CUSTOMER-TWO                     65000:2             Lo2


R1#show ip vrf interfaces
Interface       IP-Address      VRF               Protocol
Lo1             1.1.1.1         CUSTOMER-ONE      up
Lo2             2.2.2.2         CUSTOMER-TWO      up



VRF verfication on R2.

R2#show ip vrf brief
  Name                             Default RD          Interfaces
  CLIENT-ONE                       65000:1             Lo11
  CLIENT-TWO                       65000:2             Lo22

R2#show ip vrf interfaces
Interface     IP-Address      VRF            Protocol
Lo11          11.11.11.11     CLIENT-ONE     up
Lo22          22.22.22.22     CLIENT-TWO     up



Next, BGP is set up.

R1#
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
!
router bgp 65000
 bgp log-neighbor-changes
 neighbor 10.1.12.2 remote-as 65000
 !
 address-family ipv4
  neighbor 10.1.12.2 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family vpnv4
  neighbor 10.1.12.2 activate
  neighbor 10.1.12.2 send-community both
 exit-address-family
 !
 address-family ipv4 vrf CUSTOMER-TWO
  no synchronization
  network 2.2.2.0 mask 255.255.255.0
 exit-address-family
 !
 address-family ipv4 vrf CUSTOMER-ONE
  no synchronization
  network 1.1.1.0 mask 255.255.255.0
 exit-address-family



R2#
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
!
router bgp 65000
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 65000
 !
 address-family ipv4
  neighbor 10.1.12.1 activate
  no auto-summary
  no synchronization
 exit-address-family
 !
 address-family vpnv4
  neighbor 10.1.12.1 activate
  neighbor 10.1.12.1 send-community both
 exit-address-family
 !
 address-family ipv4 vrf CLIENT-TWO
  no synchronization
  network 22.22.22.0 mask 255.255.255.0
 exit-address-family
 !
 address-family ipv4 vrf CLIENT-ONE
  no synchronization
  network 11.11.11.0 mask 255.255.255.0
 exit-address-family



Note the VPNv4 capability.

R2#show ip bgp neighbor
BGP neighbor is 10.1.12.1,  remote AS 65000, internal link
  BGP version 4, remote router ID 150.1.1.1
  BGP state = Established, up for 00:00:15
  Last read 00:00:15, last write 00:00:15, hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
    Address family VPNv4 Unicast: advertised and received



BGP is learning VPNv4 routes.

R1#show ip bgp vpnv4 vrf CUSTOMER-ONE
BGP table version is 9, local router ID is 150.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65000:1 (default for vrf CUSTOMER-ONE)
*> 1.1.1.0/24       0.0.0.0                  0         32768 i
*>i11.11.11.0/24    10.1.12.2                0    100      0 i



R1#show ip bgp vpnv4 vrf CUSTOMER-TWO
BGP table version is 9, local router ID is 150.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65000:2 (default for vrf CUSTOMER-TWO)
*> 2.2.2.0/24       0.0.0.0                  0         32768 i
*>i22.22.22.0/24    10.1.12.2                0    100      0 i



R2 is also seeing the routes advertised by R1.

R2#show ip bgp vpnv4 vrf CLIENT-ONE
BGP table version is 9, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65000:1 (default for vrf CLIENT-ONE)
*>i1.1.1.0/24       10.1.12.1                0    100      0 i
*> 11.11.11.0/24    0.0.0.0                  0         32768 i
R2#


 

R2#show ip bgp vpnv4 vrf CLIENT-TWO
BGP table version is 9, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65000:2 (default for vrf CLIENT-TWO)
*>i2.2.2.0/24       10.1.12.1                0    100      0 i
*> 22.22.22.0/24    0.0.0.0                  0         32768 i



P.S. Note that this is not how you would normally configure MP-BGP for MPLS VPNs. This post is simply demonstrating the use of BGP VPNv4 address family.

Friday, May 8, 2015

400-101: BGP, Part IV:II


3.7g Implement and troubleshoot AS path manipulations


3.7g(iii) Regexp


Regular expressions use special character definitions to search and find character patterns. Within the scope of BGP, regular expressions can be used in show commands and as-path access-lists to match BGP prefixes based on the information contained in the AS_PATH attribute.

The character definitions in IOS:

Some commonly used regular expressions:
+-------------+---------------------------+
| EXPRESSION  | MEANING                   |
|-------------+---------------------------|
| .*          | Anything                  |
|-------------+---------------------------|
| ^$          | Locally originated routes |
|-------------+---------------------------|
| ^100_       | Learned from AS 100       |
|-------------+---------------------------|
| _100$       | Originated in AS 100      |
|-------------+---------------------------|
| _100_       | Any instance of AS 100    |
|-------------+---------------------------|
| ^[0-9]+$    | Directly connected ASes   |
+-------------+---------------------------+



Example: Permit only locally originated routes on R2. Ignore the private AS stuff, using an example from a previous post.

 +----------+     +--------+     +--------+
 |          |     |        |     |        |
 | AS 65001 | --- | AS 200 | --- | AS 300 |
 |    R1    |     |   R2   |     |   R3   |
 +----------+     +--------+     +--------+



R2#
interface FastEthernet0/1
 ip address 155.1.23.2 255.255.255.0
!
interface Loopback200
 ip address 200.2.2.2 255.255.255.0
!
interface Loopback201
 ip address 200.22.22.2 255.255.255.0
!
ip as-path access-list 1 permit ^$
!
route-map LOCAL-ONLY permit 10
 match as-path 1
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 200.2.2.0
 network 200.22.22.0
 neighbor 155.1.12.1 remote-as 65001
 neighbor 155.1.23.3 remote-as 300
 neighbor 155.1.23.3 remove-private-as
 neighbor 155.1.23.3 route-map LOCAL-ONLY out
 no auto-summary



R2 is originating two routes: 200.2.2.0/24 and 200.22.22.0/24. R2 is also learning routes from R1.

R2#show ip bgp
BGP table version is 9, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 100.1.1.0/24     155.1.12.1               0             0 65001 i
*> 100.11.11.0/24   155.1.12.1               0             0 65001 i
*> 150.1.1.1/32     155.1.12.1               0             0 65001 i
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i



Regular expression can also be applied to show commands to filter the output. The show ip bgp regexp ^$ displays locally originated routes.

R2#show ip bgp regexp ^$
BGP table version is 9, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i



However, only the locally originated routes are propaged to R3.

R2#show ip bgp neighbors 155.1.23.3 advertised-routes
BGP table version is 9, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i

Total number of prefixes 2

400-101: BGP, Part IV

3.7g Implement and troubleshoot AS path manipulations


3.7g(i) Local AS, allow AS in, remove private AS


 

1. local-as


The local-AS feature allows the router to appear to be a member of a second AS, in addition to its real AS. This feature can only be used for true eBGP peers, not between two peers in different confederation sub-AS.

The local-as does not replace the normal AS number advertised to its peers. Rather, it prepends the local-as to the actual AS, resulting in the AS_PATH length of two. Routes advertised to neighbors with local-as will appear to arrive via the specified AS, but will still be known to have originated in the actual AS.

Let's look at an example. R1 and R2 are in AS 100, R3 is in AS 300. However, R2 is configured to peer with R3 using AS 200.

 +--------+     +------------+     +--------+
 |        |     |            |     |        |
 | AS 100 | --- | AS 100/200 | --- | AS 300 |
 |   R1   |     |     R2     |     |   R3   |
 +--------+     +------------+     +--------+



Configuration.

R1#
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 192.168.10.0
 neighbor 10.1.12.2 remote-as 100
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 10.1.23.2 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 100
 neighbor 10.1.23.3 remote-as 300
 neighbor 10.1.23.3 local-as 200
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 10.1.23.3 255.255.255.0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 no auto-summary



From R3's perspective, R2 is peering from AS 200. Although, the BGP process on R2 is AS 100 (router bgp 100).

R3#show ip bgp summary
BGP router identifier 10.1.23.3, local AS number 300
BGP table version is 6, main routing table version 6
1 network entries using 120 bytes of memory
1 path entries using 52 bytes of memory
2/1 BGP path/bestpath attribute entries using 248 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 444 total bytes of memory
BGP activity 3/2 prefixes, 3/2 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.23.2       4   200      98      95        6    0    0 00:04:47        1



Pay attention to the AS_PATH in the learned prefix.

R3#show ip bgp
BGP table version is 6, local router ID is 150.1.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 192.168.10.0     10.1.23.2                              0 200 100 i



 

2. allowas-in


EBGP loop prevention is based on the AS_PATH attribute. If the local AS number is seen in the AS_PATH of the NLRI, that UPDATE is not accepted. What if there is a situation where the BGP AS is split in two (as demonstrated below)? 

 +--------+     +--------+     +--------+
 |        |     |        |     |        |
 | AS 100 | --- | AS 200 | --- | AS 100 |
 |   R1   |     |   R2   |     |   R3   |
 +--------+     +--------+     +--------+



Configuration.

R1#
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 172.16.16.0 mask 255.255.255.0
 network 172.16.17.0 mask 255.255.255.0
 network 192.168.10.0
 network 192.168.11.0
 neighbor 10.1.12.2 remote-as 200
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 10.1.23.2 255.255.255.0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 100
 neighbor 10.1.23.3 remote-as 100
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 10.1.23.3 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 no auto-summary



R1 is advertising four routes: 192.168.10.0/24, 192.168.11.0/24, 172.16.16.0/24, and 172.16.17.0/24.

R1#show ip bgp
BGP table version is 5, local router ID is 10.1.12.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.16.0/24   0.0.0.0                  0         32768 i
*> 172.16.17.0/24   0.0.0.0                  0         32768 i
*> 192.168.10.0     0.0.0.0                  0         32768 i
*> 192.168.11.0     0.0.0.0                  0         32768 i



Normally, the routes from R1 to R3 (via R2) would get rejected because AS 100 would be listed in the AS_PATH.

R3# debug ip bgp updates
*Mar  1 02:52:42.303: BGP(0): 10.1.23.2 rcv UPDATE about 192.168.11.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.307: BGP(0): 10.1.23.2 rcv UPDATE about 192.168.10.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.307: BGP(0): 10.1.23.2 rcv UPDATE about 172.16.17.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.311: BGP(0): 10.1.23.2 rcv UPDATE about 172.16.16.0/24 -- DENIED due to: AS-PATH contains our own AS;



To allow the UPDATES to be received, neighbor x.x.x.x allowas-in must be configured on R3.

R3#
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 neighbor 10.1.23.2 allowas-in
 no auto-summary



The routes are now installed into R3's BGP table, regardless of the AS_PATH containing R3's AS number (100).

R3#show ip bgp
BGP table version is 5, local router ID is 10.1.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.16.0/24   10.1.23.2                              0 200 100 i
*> 172.16.17.0/24   10.1.23.2                              0 200 100 i
*> 192.168.10.0     10.1.23.2                              0 200 100 i
*> 192.168.11.0     10.1.23.2                              0 200 100 i



 

3. remove-private-as


IANA has reserved a private AS number space (64512 to 65535) to converse public AS numbers (1 to 64511). The private AS numbers cannot be leaked into the global BGP table because they are not unique (EBGP uses the AS_PATH for loop prevention). The remove-private-as command strips off the private AS numbers out of the AS_PATH list before the routes are propagated to a BGP peer.

A private AS is commonly allocated when a customer connects to one ISP (single-homed or dual-homed connection). A private AS number cannot be used when the customer connects to multiple ISPs. When a private AS number is allocated to the customer, the BGP updates from the customer will have the private AS number in the AS_PATH list. The ISP should not propagate the AS_PATH with the private AS number. The neighbor x.x.x.x remove-private-as command removes the private AS number from outbound updates.

The following conditions apply:
  • Only used with eBGP peers.
  • If the update has only private AS numbers in the AS_PATH, BGP removes these numbers.
  • If the AS_PATH includes both private and public AS numbers, BGP doesn't remove the private AS numbers. This situation is considered a configuration error.
  • If the AS_PATH contains the AS number of the eBGP neighbor, BGP does not remove the private AS number.
  • If the AS_PATH contains confederations, BGP removes the private AS numbers only if they come after the confederation portion of the AS_PATH.

Example.

 +----------+     +--------+     +--------+
 |          |     |        |     |        |
 | AS 65001 | --- | AS 200 | --- | AS 300 |
 |    R1    |     |   R2   |     |   R3   |
 +----------+     +--------+     +--------+


Simple scenario: R1 is advertising its Loopback0. R2 will remove the private AS number before propagating the route to R3.


R1#
interface FastEthernet0/0
 ip address 155.1.12.1 255.255.255.0
!
interface Loopback0
 ip address 150.1.1.1 255.255.255.255
!
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 network 150.1.1.1 mask 255.255.255.255
 neighbor 155.1.12.2 remote-as 200
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 155.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 155.1.23.2 255.255.255.0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 155.1.12.1 remote-as 65001
 neighbor 155.1.23.3 remote-as 300
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 155.1.23.3 255.255.255.0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 neighbor 155.1.23.2 remote-as 200
 no auto-summary



Before the private AS is removed, R3 can see it in the AS_PATH of the 155.1.1.1/32 route.

R3#show ip bgp
BGP table version is 5, local router ID is 150.1.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 150.1.1.1/32     155.1.23.2                             0 200 65001 i



Applying the configuration

R2#
router bgp 200
 neighbor 155.1.23.3 remove-private-as



Verification. Only AS 200 is listed in the AS_PATH.

R3#show ip bgp
BGP table version is 6, local router ID is 150.1.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 150.1.1.1/32     155.1.23.2                             0 200 i

Thursday, May 7, 2015

400-101: BGP, Part III:II

3.7.d Implement, Optimize and Troubleshoot Routing Policies


3.7.d (ii) Conditional Advertisement


It is practically impossible to affect incoming traffic flows with 100% accuracy using BGP path attributes. There are methods to influence inbound routing like AS prepending or MED but traffic might still enter the AS over either link. BGP Conditional Advertisement allows the router to advertise a route only when certain conditions are met.

Conditional advertisement has two forms: advertisement of some prefixes when some other prefixes do not exist and advertisement of some prefixes when they do exist. The prefixes to be advertised are defined by a special route map called advertise-map. The condition is defined by a route map called non-exist-map for conditions that do not exist or by a route map called exist-map for conditions that do exist.

A common application for conditional advertisement is to force inbound and outbound traffic over one link and failover to the backup route only when the primary link fails.

                +--------+
                |        |
                | AS 200 |
                |        |
 +--------+     +--------+
 |        |    /
 | AS 100 | --<
 |        |    \
 +--------+     +--------+
                |        |
                | AS 300 |
                |        |
                +--------+



Let's say R1 in AS 100 uses its connection to R3 in AS 300 (directly connected network 198.51.100.0/24) as its primary link. R1's connection to R2 in AS 200 (directly connected network 192.0.2.0/24) is strictly a backup connection. R1 has a local route 203.0.113.0/24 that should be advertised to R2 only if R3 is down. This can be accomplished with BGP conditional advertisement.

In other words:
  • If 198.51.100.0/24 exists in R1's BGP table, then do not advertise 203.0.113.0/24 to R2.
  • If 198.51.100.0/24 does not exist in R1's BGP table, then advertise the 203.0.113.0/24 to R2.

Configuration.

R1#
interface Loopback0
 ip address 203.0.113.0 255.255.255.0
!
interface FastEthernet0/0
 ip address 198.51.100.1 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.0.2.1 255.255.255.0
!
ip prefix-list R1-LOCAL seq 10 permit 203.0.113.0/24
!
ip prefix-list R1-R3-NET seq 10 permit 198.51.100.0/24
!
route-map ADV-ROUTE permit 10
 match ip address prefix-list R1-LOCAL
!
route-map NON-EXIST-R1-R3 permit 10
 match ip address prefix-list R1-R3-NET
!
router bgp 100
 network 203.0.113.0 mask 255.255.255.0
 network 198.51.100.0 mask 255.255.255.0
 neighbor 192.0.2.2 remote-as 200
 neighbor 192.0.2.2 advertise-map ADV-ROUTE non-exist-map NON-EXIST-R1-R3
 neighbor 198.51.100.3 remote-as 30
0

R2#
interface FastEthernet0/0
 ip address 192.0.2.2 255.255.255.0
!
router bgp 200
 neighbor 192.0.2.1 remote-as 100


R3#
interface FastEthernet0/0
 ip address 198.51.100.3 255.255.255.0
!
router bgp 300
 neighbor 198.51.100.1 remote-as 100



Using the primary link under normal conditions.

R1#show ip bgp neigh 198.51.100.3 advertised-routes
BGP table version is 5, local router ID is 203.0.113.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 198.51.100.0     0.0.0.0                  0         32768 i
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 2



Note that 203.0.113.0/24 is not advertised to R2.

R1#show ip bgp neigh 192.0.2.2 advertised-routes
BGP table version is 5, local router ID is 203.0.113.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 198.51.100.0     0.0.0.0                  0         32768 i

Total number of prefixes 1



After the link between R1 and R3 is shutdown, 203.0.113.0/24 is advertised to R2.

R1#show ip bgp neighbors 192.0.2.2 advertised-routes
BGP table version is 7, local router ID is 203.0.113.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 1


Naturally, 198.51.100.0/24 is no longer advertised because it does not exist in R1's BGP table.

 

3.7.d(iii) Outbound Route Filtering (ORF)


The BGP ORF feature is a routing policy optimization to filter out unwanted updates at the source. ORF is enabled through the advertisement of ORF capabilities. This indicates that the BGP speaker will accept an inbound prefix-list from a neighbor and apply it locally as an outbound filter.

ORF can be configured with send and/or receive ORF capabilities. The local peer advertises the ORF capability in send mode. The remote peer receives the ORF capability in receive mode and applies the filter as an outbound policy.

R1 is advertising the following networks to R3.

R1#show ip bgp neighbors 150.1.3.3 advertised-routes
BGP table version is 8, local router ID is 150.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 192.0.2.0        0.0.0.0                  0         32768 i
*> 198.51.100.0     0.0.0.0                  0         32768 i
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 3


R3 has the following inbound filters applied.

ip prefix-list ORF-DENY seq 5 deny 203.0.113.0/24
ip prefix-list ORF-DENY seq 10 permit 0.0.0.0/0 le 32
!
router bgp 200
 no synchronization
 neighbor 150.1.1.1 remote-as 100
 neighbor 150.1.1.1 ebgp-multihop 2
 neighbor 150.1.1.1 update-source Loopback0
 neighbor 150.1.1.1 prefix-list ORF-DENY in
 no auto-summary



It is unnecessary to send 203.0.113.0/24 to R3 because the route is denied as soon as it is received.

*BGP(0): 150.1.1.1 rcvd 203.0.113.0/24 -- DENIED due to: distribute/prefix-list;


R3's BGP table (excluding locally originated routes).

R3#show ip bgp | exclude 0.0.0.0
BGP table version is 19, local router ID is 150.1.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 192.0.2.0        150.1.1.1                0             0 100 i
*> 198.51.100.0     150.1.1.1                0             0 100 i



To enable the ORF feature, R1 must be configured with the ORF receive capability and R3 with the ORF send capability.

R1#
router bgp 100
 neighbor 150.1.3.3 capability orf prefix-list receive


R3#
router bgp 200
 neighbor 150.1.1.1 prefix-list ORF-DENY in
 neighbor 150.1.1.1 capability orf prefix-list send



R3's inbound routing policy is now applied outbound on R1.

R1#show ip bgp neighbors 150.1.3.3 advertised-routes
BGP table version is 20, local router ID is 150.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 192.0.2.0        0.0.0.0                  0         32768 i
*> 198.51.100.0     0.0.0.0                  0         32768 i

Total number of prefixes 2


With the full Internet routing table consisting of hundreds of thousands of routes, the benefit of minimized resource utilization due to ORF is clear. Although the same end result is achieved, ORF is much more efficient as compared to traditional inbound route filtering.

3.7.d (iv) Communities, extended communities


A community is a group of prefixes that share some common property and can be assigned the BGP community attribute. The BGP Community attribute is an optional transitive attribute of variable length. The attribute is a four-octect value, with the AS number typically encoded in the first two octects followed by a unique two-byte value.

BGP communities themselves do not affect the BGP best path selection but they can be used as flags to mark a set of routes. The community and extended communities attributes can trigger routing decisions, such as acceptance, rejection, preference, or redistribution. A prefix can have more than one community attributes. A BGP speaker can act on one, some or all the attributes. A router can also add or modify the community attributes before advertising to other peers.

BGP Community Attribute
++++++++++++++++++++++++++++++++++++++++
| Autonomous System Number (2 octects) |
++++++++++++++++++++++++++++++++++++++++
| Value (2 octets)                     |
++++++++++++++++++++++++++++++++++++++++


Communities can be defined in decimal or hexadecimal. Some community ranges are reserved and some values are used for specific purposes. For example, 0 to 65,535 (0x00000000 to 0x0000FFFF) and 4,294,967,041 to 4,294,967,295 (0xFFFF0000 to 0xFFFFFFFF) has been reserved by IANA.

Specific-purpose community attributes include:
  • INTERNET (0): The default community. By default, all routes belong to this community and all routes in this category are advertised freely.
  • NO_EXPORT (4,294,967,041 or 0xFFFFFF01): Routes with this COMMUNITY attribute must not be advertised outside of the local AS or confederation.
  • NO_ADVERTISE (4,294,967,042 or 0xFFFFFF02): Routes with this COMMUNITY attribute must not be advertised to any peer.
  • LOCAL_AS (4,294,967,043 or 0xFFFFFF03): Routes with this COMMUNITY attribute must not be advertised to any eBGP or external confederation peer (referred to as NO_EXPORT-SUBCONFED in RFC 1997).

The 4-octet community value does not provide enough expansion and flexibility to accommodate VPN requirements. This lead to the creation of extended communities. An extended community is an 8-octet value that is also divided into two main sections. The first 2 octets of the community encode a type field while the last 6 octets carry a unique set of data in a format defined by the type field. Extended communities provide a larger range for grouping or categorizing communities.

BGP Extended Community Attribute
++++++++++++++++++++++++++++++++++++++++++++++++++
| I | T | Type High (4 bits) | Type Low (8 bits) |
++++++++++++++++++++++++++++++++++++++++++++++++++
|                                                |
|                                                |
|              Value (6 octets)                  |
|                                                |
|                                                |
++++++++++++++++++++++++++++++++++++++++++++++++++


I = IANA or IETF
T = transitive or non-transitive

The Route Target extended community is in popular use wihin MPLS VPNs.The Route Target Community identifies one or more routers that may receive a set of routes (that carry this Community) carried by BGP.

BGP communities are not propagated by default. The neighbor x.x.x.x send-community [standard | extended | both] is required.

Let's look at an example. R1 in AS 100 has the following routes: 192.168.10.0/24, 192.168.11.0/24, 172.16.16.0/24, and 172.16.17.0/24. R1 is going to advertise the 172.16.16.0/24 and 172.16.17.0/24 networks with a community attribute NO_EXPORT to prevent AS 200 from propagating those routes further to AS 300.

 +--------+     +--------+     +--------+
 |        |     |        |     |        |
 | AS 100 | --- | AS 200 | --- | AS 300 |
 |        |     |        |     |        |
 +--------+     +--------+     +--------+


The configuration.

ip prefix-list 172-NETS seq 5 permit 172.16.16.0/24
ip prefix-list 172-NETS seq 10 permit 172.16.17.0/24
!
!
!
route-map NO-EXPORT permit 10
 match ip address prefix-list 172-NETS
 set community no-export
!
route-map NO-EXPORT permit 20
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 172.16.16.0 mask 255.255.255.0
 network 172.16.17.0 mask 255.255.255.0
 network 192.168.10.0
 network 192.168.11.0
 neighbor 10.1.12.2 remote-as 200
 neighbor 10.1.12.2 send-community both
 neighbor 10.1.12.2 route-map NO-EXPORT out
 no auto-summary


R2 and R3 have only basic BGP configuration for peering.

Packet capture of the BGP UPDATE as sent from R1 to R2.

Border Gateway Protocol - UPDATE message
 Path Attributes
  Path Attribute - COMMUNITIES: NO_EXPORT
   Flags: 0xc0: Optional, Transitive, Complete
    Type Code: COMMUNITIES (8)
    Length: 4
     Communities: NO_EXPORT
       Community Well-known: NO_EXPORT (0xffffff01)

 Network Layer Reachability Information (NLRI)
  172.16.16.0/24
    NLRI prefix length: 24
    NLRI prefix: 172.16.16.0 (172.16.16.0)
  172.16.17.0/24
    NLRI prefix length: 24
    NLRI prefix: 172.16.17.0 (172.16.17.0)



R2 receives all the advertised routes.

R2#show ip bgp
BGP table version is 7, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.16.0/24   10.1.12.1                0             0 100 i
*> 172.16.17.0/24   10.1.12.1                0             0 100 i
*> 192.168.10.0     10.1.12.1                0             0 100 i
*> 192.168.11.0     10.1.12.1                0             0 100 i



However, R2 does not advertise the NO_EXPORT routes to R3.

R2#show ip bgp 172.16.16.0 255.255.255.0
BGP routing table entry for 172.16.16.0/24, version 6
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Not advertised to any peer
  100
    10.1.12.1 from 10.1.12.1 (192.168.11.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-export



R2#show ip bgp neighbor 10.1.23.3 advertised-routes
BGP table version is 7, local router ID is 150.1.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 192.168.10.0     10.1.12.1                0             0 100 i
*> 192.168.11.0     10.1.12.1                0             0 100 i

Total number of prefixes 2



3.7.d(v) Multi-homing


Multihoming is connecting your network to two different ISPs. Multihoming provides redundancy by offering a backup route in case of a link failure and network optimization by selecting the ISP which offers the best path to a resource.

When running BGP with multiple ISPs, there is a risk that the local AS becomes a transit AS. Internet traffic could then pass through the AS and potentially consume all bandwidth and CPU resources. One method to guarantee that the local AS will not become a transit AS is to allow only locally generated routes to be advertised to both ISP - filtering the Internet routes going from one ISP to the other. This can be done with an outbound policy that permits only routes from the local AS.

Regular expressions use character definitions to match patterns. For example, ^ = start of string and $=end of string. Together with numbers, these characters can be used to match locally originated BGP routes or routes that were advertised through a particular AS (included in the AS_PATH). This is accomplished by ^$ (locally originated route; empty AS_PATH) and ^100$ (only AS 100 in the AS_PATH), respectively.


ip as-path access-list 10 permit ^$
!
route-map LOCAL-ONLY permit 10
 match as-path 10
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out



Further, the configuration can be narrowed down to receive only directly connected routes from each ISP.

ip as-path access-list 20 permit ^100$
!
route-map AS-100-ONLY permit 10
 match as-path 20
!
ip as-path access-list 30 permit ^200$
!
route-map AS-200-ONLY permit 10
 match as-path 30
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 1.1.1.1 route-map AS-100-ONLY in
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 route-map AS-200-ONLY in


In addition to the BGP configuration, a default route is required. There are three main methods to advertise the default route:
  1. Allowing the default route in the inbound policy.
  2. Using an IGP.
  3. Installing a static default route.
Since this document talks about BGP, let's look at the first option. The default route is added in the inbound policy.

ip as-path access-list 20 permit ^100$
!
ip as-path access-list 30 permit ^200$
!
ip prefix-list DEFAULT-ROUTE seq 10 permit 0.0.0.0/0
!
route-map AS-100-ONLY permit 10
 match as-path 20
route-map AS-100-ONLY permit 20
 match ip address prefix-list DEFAULT-ROUTE
!
route-map AS-200-ONLY permit 10
 match as-path 30
route-map AS-200-ONLY permit 20
 match ip address prefix-list DEFAULT-ROUTE
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 1.1.1.1 route-map AS-100-ONLY in
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 route-map AS-200-ONLY in