www.howtonetwork.org

CCNA & CCNP Certifcation Training

  • About
  • Contact
  • FAQ
  • Join
  • Home
  • CCNA
    • ICND1
    • ICND2
    • 101 CCNA LABS
  • CCNP
    • ROUTE
    • SWITCH
    • TSHOOT
    • 101 CCNP LABS
  • CompTIA
    • Security+
    • Network+
  • Design
    • CCDA
    • CCDP
You are here: Home / ROUTE / Module 7 / Advanced BGP – Border Gateway Protocol Route Filtering – Part 1

Advanced BGP – Border Gateway Protocol Route Filtering – Part 1

In Cisco IOS software, there are many techniques that can be used to implement a route filtering policy when using BGP. As previously stated, BGP is first and foremost a policy configuration tool. Given this, it is important to understand not only basic BGP implementation, as described in the earlier chapter and in previous sections of this chapter, but also how to implement an effective policy control solution when using BGP. The following route filtering policy control tools are described in this section:

  • Effective Policy Control Using IP Prefix Lists
  • Effective Policy Control with Communities
  • Effective Policy Control Using AS PATH Filters

Effective Policy Control Using IP Prefix Lists

Prefix lists, which were described in detail earlier in this guide, can be used for inbound and outbound filtering policies. For BGP, prefix lists can be applied in two ways:

  • Using the neighbor [address] prefix-list [name] <in|out> command
  • Using the neighbor [address] route-map [name] <in|out> command

The neighbor [address] prefix-list [name] <in|out> command applies prefix list filtering in the inbound or outbound direction for the specified neighbor or peer group. As an example, the following output shows the BGP RIB of an iBGP speaker that is receiving prefixes from another iBGP speaker:

R2#show ip bgp
BGP table version is 7, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*>i172.16.0.0/24    1.1.1.1                  0    100      0 i
*>i172.16.1.0/24    1.1.1.1                  0    100      0 i
*>i172.16.2.0/24    1.1.1.1                  0    100      0 i
*>i172.16.3.0/24    1.1.1.1                  0    100      0 i

If, for example, we only wanted this router to accept the 172.16.0.0/24 and 172.16.2.0/24 prefixes, the following configuration would be implemented on the local router:

R2(config)#ip prefix-list FILTER-PREFIXES seq 5 permit 172.16.0.0/24
R2(config)#ip prefix-list FILTER-PREFIXES seq 7 permit 172.16.2.0/24
R2(config)#router bgp 65001
R2(config-router)#neighbor 1.1.1.1 prefix-list FILTER-PREFIXES in
R2(config-router)#exit
R2(config)#exit
R2#clear ip bgp * soft in

Following this configuration, the BGP RIB on the same router now shows the following:

R2#show ip bgp
BGP table version is 9, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*>i172.16.0.0/24    1.1.1.1                  0    100      0 i
*>i172.16.2.0/24    1.1.1.1                  0    100      0 i

Following the configuration of inbound or outbound prefix list filters, you can use the show ip bgp neighbors [address] command to verify the filter applied to the neighbor as follows:

R2#show ip bgp neighbors 1.1.1.1
BGP neighbor is 1.1.1.1,  remote AS 65001, internal link
BGP version 4, remote router ID 1.1.1.1
BGP state = Established, up for 01:49:02[Truncated Output]Incoming update prefix filter list is FILTER-PREFIXES
Sent       Rcvd
Prefix activity:               —-       —-
Prefixes Current:               0          2 (Consumes 104 bytes)
Prefixes Total:                 0         10
Implicit Withdraw:              0          8
Explicit Withdraw:              0          0
Used as bestpath:             n/a          2
Used as multipath:            n/a          0

Outbound    Inbound
Local Policy Denied Prefixes:    ——–    ——-
prefix-list                           0          2
Suppressed duplicate:                 0          6
Bestpath from this peer:              4        n/a
Bestpath from iBGP peer:              1        n/a
Total:                                5          8

[Truncated Output]

In addition to showing the prefix list used for inbound filtering, this command also shows the current number of received prefixes, as well as the count of prefixes denied by the prefix list filtering configuration, as whether those are in the inbound or outbound direction. These two sections are printed in bold font in the previous output.

In Cisco IOS software, the show ip bgp prefix-list [name] command can also be used to further valid inbound or outbound prefix list filtering. This command filters the BGP RIB output based on the configuration in the specified prefix list. The following example illustrates how to use this command to filter BGP RIB output based on the named prefix list:

R2#show ip bgp prefix-list FILTER-PREFIXES
BGP table version is 9, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*>i172.16.0.0/24    1.1.1.1                  0    100      0 i
*>i172.16.2.0/24    1.1.1.1                  0    100      0 i

NOTE: Keep in mind that the same configuration could also have been applied in the outbound direction on the router advertising these prefixes.

The neighbor [address] route-map [name] <in|out> command can also be used to perform prefix list filtering. The primary advantage of using route maps is their flexibility, as has been demonstrated in previous chapters. For example, in addition to matching a specified prefix list, the same route map could also be used to perform other functions, such as path attribute manipulation, within the same configuration. The following example illustrates how to use a route map to perform the same filtering illustrated in the previous example:

R2(config)#ip prefix-list FILTER-PREFIXES seq 5 permit 172.16.0.0/24
R2(config)#ip prefix-list FILTER-PREFIXES seq 7 permit 172.16.2.0/24
R2(config)#route-map INBOUND-FILTER permit 10
R2(config-route-map)#match ip address prefix-list FILTER-PREFIXES
R2(config-route-map)#exit
R2(config)#router bgp 65001
R2(config-router)#neighbor 1.1.1.1 route-map INBOUND-FILTER in
R2(config-router)#exit
R2(config)#exit
R2#clear ip bgp * soft in

As with direct prefix list configuration, the show ip bgp neighbors command can be used to validate the applied route map and view information on the number of prefixes

R2#show ip bgp neighbors 1.1.1.1
BGP neighbor is 1.1.1.1,  remote AS 65001, internal link
BGP version 4, remote router ID 1.1.1.1
BGP state = Established, up for 02:05:24[Truncated Output]Inbound path policy configured
  Route map for incoming advertisements is INBOUND-FILTER
Sent       Rcvd
Prefix activity:               —-       —-
Prefixes Current:               0          2 (Consumes 104 bytes)
Prefixes Total:                 0         16
Implicit Withdraw:              0         14
Explicit Withdraw:              0          0
Used as bestpath:             n/a          2
Used as multipath:            n/a          0

Outbound    Inbound
Local Policy Denied Prefixes:    ——–    ——-
route-map:                            0          2
prefix-list                           0          2
Suppressed duplicate:                 0         10
Bestpath from this peer:              6        n/a
Bestpath from iBGP peer:              1        n/a
Total:                                7         14

[Truncated Output]

And finally, the show ip bgp route-map [name] command can be used to filter the contents of the BGP RIB, showing only those matched by the specified route map:

R2#show ip bgp route-map INBOUND-FILTER
BGP table version is 13, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*>i172.16.0.0/24    1.1.1.1                  0    100      0 i
*>i172.16.2.0/24    1.1.1.1                  0    100      0 i

NOTE: The same policy could also be implemented in the outbound direction on R1 and the same commands used to validate this configuration.

In enterprise networks, one of the most common (and recommended) uses for prefix lists is to filter Martian addresses. Martians are networks that should not be routed on the Internet.  In essence, these addresses are illegal on the Internet, although they may be used within private enterprise networks. When implementing an inbound route filtering policy for BGP, the following Martian addresses should be filtered in UPDATE messages received from the ISP:

  • Network 0.0.0.0/8 Addresses – 0.0.0.0/8 (This does not include the default 0.0.0.0/0)
  • RFC 1918 Address Space – 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16
  • System Local Address Space – 127.0.0.0/8
  • Autoconfiguration Address Space – 169.254.0.0/16
  • Test Network Address Space – 192.0.2.0/24
  • Class D and Class E Address Space – 224.0.0.0/3

The following configuration illustrates how to configure a local BGP speaker peered to an ISP BGP speaker in AS 456 to filter Martian addresses and allow all other prefixes:

R3(config)#ip prefix-list NO-MARTIANS seq 1 deny 0.0.0.0/8 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 2 deny 10.0.0.0/8 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 3 deny 172.16.0.0/12 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 4 deny 192.168.0.0/16 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 5 deny 127.0.0.0/8 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 6 deny 169.254.0.0/16 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 7 deny 192.0.2.0/24 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 8 deny 224.0.0.0/3 le 32
R3(config)#ip prefix-list NO-MARTIANS seq 9 permit 0.0.0.0/0 le 32
R3(config)#router bgp 123
R3(config-router)#neighbor 150.1.1.2 remote-as 456
R3(config-router)#neighbor 150.1.1.2 description ISP Internet Router
R3(config-router)#neighbor 150.1.1.2 prefix-list NO-MARTIANS in
R3(config-router)#exit

The same configuration can also be used with a route map that matches the specified prefix list.

Effective Policy Control with Communities

In the previous chapter, when we were learning about the different BGP attributes, we learned that the COMMUNITY attribute provides a way of grouping destinations, called Communities, to which routing decisions (such as acceptance, preference, and redistribution) can be applied.

The attribute is encoded as a four-octet value where the first two octets represent an AS number and the remaining two octets represent a locally defined value. There are two types of communities that exist. These two types are:

  • Well-known Communities
  • Private Communities

The well-know communities are communities that have predefined meanings. These are:

  • NO_EXPORT
  • NO_ADVERTISE
  • INTERNET
  • LOCAL_AS

Unlike the well-known communities, private communities must be manually defined by the network administrators and actions for prefixes assigned those communities must also be explicitly defined. Private communities are typically configured using the AA:NN format, where AA represents the AS Number and NN is a randomly selected number.

NOTE: The implementation, use and configuration of private communities is beyond the scope of the current ROUTE exam and will not be illustrated in this chapter. Instead, the chapter will focus exclusively on the use of well-known communities.

To better understand the use of well-known communities, consider the topology in Figure 7-14:

ABGP_Lesson6_img1

Fig. 7-14. Understanding BGP Communities

Figure 7-13 shows an enterprise that is multihomed to two ISPs as well as two partners. This enterprise is receiving full Internet tables from both ISPs as well as routes for the prefixes owned by the two partners. Without any type of route filtering, the Internet prefixes received from the ISPs will be advertised to the partners. In addition to this, the prefixes that are also received from the partners will be advertised to the ISPs. This is not desirable.

The first reason is that if the enterprise advertises the Internet routes to the partners, these two routing domains might prefer the path via the enterprise to reach prefixes in AS 1 and 2, in addition to any other Internet-based prefixes that have a shorter AS_PATH via the enterprise network.  The second reason is AS 1 and AS 2 might also prefer the path through AS 123 for prefixes originated in AS 456 and AS 789. The third reason is that the partner ASes could also now prefer the path via AS 123 to reach each other. Regardless of the way you look at it, the enterprise becomes a transit autonomous system for both the partner networks and the ISPs.

Instead of using prefix lists to filter prefixes in the inbound and outbound directions, AS 123 could simply route filtering by using communities. For example, using a simple policy, the enterprise edge routers could be configured to set the NO_EXPORT community on all of the prefixes received from the ISPs and the partners.

The NO_EXPORT well-known community prevents BGP prefixes that are specifically assigned this predefined community attribute value from being advertised to any eBGP peers. The prefixes, however, will continue to be advertised to all other iBGP speakers within the local AS. This solution means that the Internet routes received from the ISPs will not be advertised to either partner. Additionally, the prefixes received from both partners will not be advertised to the ISPs or the other partner. Only AS 123 maintains full reachability to all other ASes.

Referencing the topology illustrated in Figure 7-14, enterprise edge router is receiving a partial routing table plus a default route from the ISP. The BGP RIB on E1 shows the following routes:

E1#show ip bgp
BGP table version is 54, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*> 0.0.0.0          10.0.3.2                               0 1 i
*> 120.0.0.0/16     10.0.3.2                 0             0 1 10 20 i
*> 121.0.0.0/16     10.0.3.2                 0             0 1 10 20 i
*> 122.0.0.0/16     10.0.3.2                 0             0 1 10 20 i
*> 123.0.0.0/16     10.0.3.2                 0             0 1 10 20 i
*> 145.0.0.0        10.0.3.2                 0             0 1 10 20 i
*> 145.1.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 155.2.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 155.3.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 160.0.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 161.0.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 162.0.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 163.0.0.0        10.0.3.2                 0             0 1 15 30 45 i
*> 175.0.0.0        10.0.3.2                 0             0 1 88 i
*> 175.1.0.0        10.0.3.2                 0             0 1 88 i
*> 175.2.0.0        10.0.3.2                 0             0 1 88 i
*> 175.3.0.0        10.0.3.2                 0             0 1 88 i
Network          Next Hop            Metric LocPrf Weight Path
*> 180.0.0.0        10.0.3.2                 0             0 1 88 i
*> 181.0.0.0        10.0.3.2                 0             0 1 88 i
*> 182.0.0.0        10.0.3.2                 0             0 1 88 i
*> 183.0.0.0        10.0.3.2                 0             0 1 2 4 6 8 i
*> 184.0.0.0        10.0.3.2                 0             0 1 2 4 6 8 i
*> 185.0.0.0        10.0.3.2                 0             0 1 2 4 6 8 i
*> 190.0.0.0        10.0.3.2                 0             0 1 2 4 6 8 i
*> 191.0.0.0        10.0.3.2                 0             0 1 2 4 6 8 i
*> 202.0.0.0/16     10.0.3.2                 0             0 1 i
*> 203.0.0.0/16     10.0.3.2                 0             0 1 i
*> 204.0.0.0/16     10.0.3.2                 0             0 1 i
*> 205.0.0.0/16     10.0.3.2                 0             0 1 i

The received prefixes are advertised to peers E2, E3, and E4. Taking router E2, for example, the same prefixes are then advertised to the partner router, along with the 150.254.0.0/16 prefix which is owned by the enterprise. In addition to this, the prefix that router E4 receives from Partner B is also included in the advertised prefixes. The prefixes that are advertised to router P1 can be validated using the show ip bgp neighbors [address] advertised-routes command. The output of this command on E3 shows the following advertisements:

E3#show ip bgp neighbors 10.0.9.2 advertised-routes
BGP table version is 70, 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
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork          Next Hop            Metric LocPrf Weight Path
*>i0.0.0.0          10.0.0.2                 0    100      0 1 i
*>i120.0.0.0/16     10.0.0.2                 0    100      0 1 10 20 i
*>i121.0.0.0/16     10.0.0.2                 0    100      0 1 10 20 i
*>i122.0.0.0/16     10.0.0.2                 0    100      0 1 10 20 i
*>i123.0.0.0/16     10.0.0.2                 0    100      0 1 10 20 i
*>i145.0.0.0        10.0.0.2                 0    100      0 1 10 20 i
*>i145.1.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*> 150.254.0.0      0.0.0.0                  0         32768 i
*>i155.2.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i155.3.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i160.0.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i161.0.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i162.0.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i163.0.0.0        10.0.0.2                 0    100      0 1 15 30 45 i
*>i175.0.0.0        10.0.0.2                 0    100      0 1 88 i
*>i175.1.0.0        10.0.0.2                 0    100      0 1 88 i
*>i175.2.0.0        10.0.0.2                 0    100      0 1 88 i
Network          Next Hop            Metric LocPrf Weight Path
*>i175.3.0.0        10.0.0.2                 0    100      0 1 88 i
*>i180.0.0.0        10.0.0.2                 0    100      0 1 88 i
*>i181.0.0.0        10.0.0.2                 0    100      0 1 88 i
*>i182.0.0.0        10.0.0.2                 0    100      0 1 88 i
*>i183.0.0.0        10.0.0.2                 0    100      0 1 2 4 6 8 i
*>i184.0.0.0        10.0.0.2                 0    100      0 1 2 4 6 8 i
*>i185.0.0.0        10.0.0.2                 0    100      0 1 2 4 6 8 i
*>i190.0.0.0        10.0.0.2                 0    100      0 1 2 4 6 8 i
*>i191.0.0.0        10.0.0.2                 0    100      0 1 2 4 6 8 i
*>i202.0.0.0/16     10.0.0.2                 0    100      0 1 i
*>i203.0.0.0/16     10.0.0.2                 0    100      0 1 i
*>i204.0.0.0/16     10.0.0.2                 0    100      0 1 i
*>i205.0.0.0/16     10.0.0.2                 0    100      0 1 i
*>i222.0.0.0/16     10.0.1.2                 0    100      0 789 iTotal number of prefixes 31

Prev

Next

About Us

This is a free bonus site for members of www.howtonetwork.com

Copyright

The content on this copyright Reality Press Ltd.
Copyright Reality Press Ltd.