Friday, July 11, 2008

BGP - expanded community-lists

BGP expanded community-lists are more flexible than their standard counterparts because they can match on regexp instead of just a community string. Here you can see the differences:

R4(config)#ip community-list standard STANDARD permit ?
<1-4294967295> community number
aa:nn community number
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)

R4(config)#ip community-list expanded EXPANDED permit ?
LINE An ordered list as a regular-expression


Now for a little lab. R1 and R2 are both going to EBGP peer with R4. R4 will then EBGP peer with R3. R1 and R2 will each send routes with different community strings to R4, along with routes without a community. We will use an expanded list to match certain community values. Hopefully, we can get it done with one permit statement.

R1 has 4 loopback networks:
1.0.0.0/24
1.0.1.0/24
1.0.2.0/24
1.0.3.0/24

R2 has 4 loopback networks:
2.0.0.0/24
2.0.1.0/24
2.0.2.0/24
2.0.3.0/24

R1 is sending community 100 with its first two loopbacks
R2 is sending community 200 with its first two loopbacks
The other loopbacks do not have a community attached.
Here is how we do it on R1, R2 is similar:

R1(config)#ip prefix-list LOOP1 permit 1.0.0.0/24
R1(config)#ip prefix-list LOOP1 permit 1.0.1.0/24
R1(config)#route-map setcom
R1(config-route-map)#match ip address prefix LOOP1
R1(config-route-map)#set commu 100
R1(config-route-map)#exit
R1(config)#route-map setcom perm 20
R1(config-route-map)#exit
R1(config)#router bgp 65000
R1(config-router)#neighbor 172.12.14.4 send-community
R1(config-router)#neighbor 172.12.14.4 route-map setcom out


Verify on R4 (this shows R4 is receiving all loopbacks)

R4#sho ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/24 172.12.14.1 0 0 65000 i
*> 1.0.1.0/24 172.12.14.1 0 0 65000 i
*> 1.0.2.0/24 172.12.14.1 0 0 65000 i
*> 1.0.3.0/24 172.12.14.1 0 0 65000 i
*> 2.0.0.0/24 172.12.24.2 0 0 65000 i
*> 2.0.1.0/24 172.12.24.2 0 0 65000 i
*> 2.0.2.0/24 172.12.24.2 0 0 65000 i
*> 2.0.3.0/24 172.12.24.2 0 0 65000 i


Here are the loopbacks with community attributes:

R4#show ip bgp community 100 | begin Net
Network Next Hop Metric LocPrf Weight Path
* 1.0.0.0/24 172.12.14.1 0 0 65000 i
* 1.0.1.0/24 172.12.14.1 0 0 65000 i
R4#show ip bgp community 200 | begin Net
Network Next Hop Metric LocPrf Weight Path
* 2.0.0.0/24 172.12.24.2 0 0 65000 i
* 2.0.1.0/24 172.12.24.2 0 0 65000 i

Here is R3:

R3#show ip bgp

Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/24 172.12.34.4 0 400 65000 i
*> 1.0.1.0/24 172.12.34.4 0 400 65000 i
*> 1.0.2.0/24 172.12.34.4 0 400 65000 i
*> 1.0.3.0/24 172.12.34.4 0 400 65000 i
*> 2.0.0.0/24 172.12.34.4 0 400 65000 i
*> 2.0.1.0/24 172.12.34.4 0 400 65000 i
*> 2.0.2.0/24 172.12.34.4 0 400 65000 i
*> 2.0.3.0/24 172.12.34.4 0 400 65000 i


Now we will configure R4 to send only routes with community 100 or 200 to R3:

R4(config)#ip community-list expanded EXPANDED permit [1-2]00
R4(config)#route-map filtercom
R4(config-route-map)#match community ?
<1-99> Community-list number (standard)
<100-500> Community-list number (expanded)
WORD Community-list name
R4(config-route-map)#match community EXPANDED
R4(config-route-map)#exit
R4(config)#router bgp 400
R4(config-router)#neighbor 172.12.34.3 route-map filtercom out


Let's check on R3:

R3#show ip bgp
BGP table version is 66, 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, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/24 172.12.34.4 0 400 65000 i
*> 1.0.1.0/24 172.12.34.4 0 400 65000 i
*> 2.0.0.0/24 172.12.34.4 0 400 65000 i
*> 2.0.1.0/24 172.12.34.4 0 400 65000 i


In this example the regexp string [1-2]00 matched either 100 or 200 an only allowed these routes through to R3.

Thursday, July 10, 2008

OSPF - dead time expiring

I was setting up a frame-relay lab a few moments ago and I ran into strange issue. R5 and R6 are going to connect via EBGP with their loopbacks. To connect to each other's loopbacks I was using OSPF over the Frame cloud.

However, I kept getting this message on R6:

R6#
Mar 1 00:34:18.895: %OSPF-5-ADJCHG: Process 1, Nbr 5.5.5.5 on Serial1/1 from FULL to DOWN, Neighbor Down: Dead timer expired
R6#
Mar 1 00:34:46.323: %OSPF-5-ADJCHG: Process 1, Nbr 5.5.5.5 on Serial1/1 from LOADING to FULL, Loading Done
R6#

These are point-to-multipoint links by the way. I started monitoring the neighbor relationship to se if hello's were being received. I was alarmed when I saw this:

R6#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
5.5.5.5 0 FULL/ - 00:01:08 172.14.45.5 Serial1/1
4.4.4.4 0 FULL/ - 00:01:50 172.14.45.4 Serial1/1

The dead time crept well below 1:20 which is the period during which I should have received a hello. I ran "debug ip ospf packet" on R6 and was not receiving any hellos from R5. But how was the adjacency forming in the first place! It did however receive replies when R6 initiated the process. This was immediately after the neighbor went down.

So I did some more searching on R5 and found this:

R5#show run int s1/1
Building configuration...

Current configuration : 217 bytes
!
interface Serial1/1
ip address 172.14.45.5 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-multipoint
serial restart-delay 0
frame-relay map ip 172.14.45.6 506
no frame-relay inverse-arp
end

What's the problem? No broadcast statement on the frame-relay map command!

Wednesday, July 9, 2008

Frame relay - debug frame events during inverse arp

I was curious about the output of this debugging command so I decided to dive a little further. Here is what I found.

R1#debug frame-relay events

LMI status received about which DLCIs are active:

*Mar 1 00:11:23.903: Serial1/0: preparing IP inarp on 102
*Mar 1 00:11:23.903: Serial1/0: preparing IP inarp on 105
*Mar 1 00:11:23.907: Serial1/0: preparing IP inarp on 104


I received an INARP:

*Mar 1 00:11:24.015: Serial1/0: FR ARP input
*Mar 1 00:11:24.019: datagramstart = 0x7A0124E, datagramsize = 34
*Mar 1 00:11:24.019: FR encap = 0x18610300
*Mar 1 00:11:24.019: 80 00 00 00 08 06 00 0F 08 00 02 04 00 09 00 00
*Mar 1 00:11:24.023: 0A 00 00 02 18 61 0A 00 00 01 01 02 00 00
*Mar 1 00:11:24.023:
*Mar 1 00:11:24.023: Serial1/0: inarp received on 102
R1#

R1#show frame-relay map Serial1/0 (up): ip 10.0.0.2 dlci 102(0x66,0x1860), dynamic, broadcast,, status defined, active

Analysis:

Datagram size: 34 bytes. The total size of this frame packet is 34 bytes. In Wireshark this be the "bytes on the wire"

FR Encap: FR encap = 0x18610300. The 1861 is the upper (0x18) and lower (0x61) DLCI values. The 0x18 is hex which in binary is 00011000 or 24 in decimal. But remember in this octet only the first 6 bits are used for the DLCI and the rest are in the 2nd octet. That means 000110XXXX will be our DLCI value where XXXX is filled in by the first 4 bits of the 2nd octet. So far we have 000110XXXX = 96 (not 24 or 6!). The 2nd octet is 0x61 which is 01100001 in binary. We are concerned with the first 4 bits and we replace the XXXX with 0110 which leaves us with 0001100110 or 102. 102 is what we have in our show frame-relay map output.

The second half of the FR Encap line is 0300 which is the control code and some padding.

In the next 2 lines we have the hex output of our packet. Below is a screenshot of the packet: