Sunday, 10 June 2012

BGP with Unequal Cost paths

This posting covers how we can handle load sharing with unequal cost paths between two BGP Autonmous Systems.

This 6 router topology has two BGP Autonomous Systems (AS 123 and AS 456) with two exit points between them, one has a 128kbps path (R2-R4), and the other a 192kbps path (R3-R5)

 Below are our initial configurations:

R1
hostname R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
 ip ospf 1 area 123
!
interface FastEthernet0/0
 ip address 10.1.111.1 255.255.255.0
 ip ospf 1 area 123
 no shutdown
!
router bgp 123
 no bgp default ipv4-unicast
 neighbor 2.2.2.2 remote-as 123
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 update-source Loopback0
 !
 address-family ipv4
  neighbor 2.2.2.2 activate
  neighbor 3.3.3.3 activate
  no auto-summary
  no synchronization
  network 1.1.1.1 mask 255.255.255.255
 exit-address-family
!

R2
hostname R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
 ip ospf 1 area 123
!
interface FastEthernet0/0
 ip address 10.1.111.2 255.255.255.0
 ip ospf 1 area 123
 no shutdown
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
 no shutdown
!
interface Serial0/0.24 point-to-point
 bandwidth 128
 ip address 10.1.24.2 255.255.255.0
 snmp trap link-status
 frame-relay interface-dlci 204
!
router bgp 123
 no bgp default ipv4-unicast
 neighbor 1.1.1.1 remote-as 123
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 10.1.24.4 remote-as 456
 !
 address-family ipv4
  neighbor 1.1.1.1 activate
  neighbor 1.1.1.1 next-hop-self
  neighbor 3.3.3.3 activate
  neighbor 3.3.3.3 next-hop-self
  neighbor 10.1.24.4 activate
  no auto-summary
  no synchronization
  network 2.2.2.2 mask 255.255.255.255
 exit-address-family
!

R3
hostname R3
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
 ip ospf 1 area 123
!
interface FastEthernet0/0
 ip address 10.1.111.3 255.255.255.0
 ip ospf 1 area 123
 no shutdown
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
 no shutdown
!
interface Serial0/0.35 point-to-point
 bandwidth 192
 ip address 10.1.35.3 255.255.255.0
 snmp trap link-status
 frame-relay interface-dlci 305
!
router bgp 123
 no bgp default ipv4-unicast
 neighbor 1.1.1.1 remote-as 123
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 2.2.2.2 remote-as 123
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 10.1.35.5 remote-as 456
 !
 address-family ipv4
  neighbor 1.1.1.1 activate
  neighbor 1.1.1.1 next-hop-self
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 next-hop-self
  neighbor 10.1.35.5 activate
  no auto-summary
  no synchronization
  network 3.3.3.3 mask 255.255.255.255
 exit-address-family
!

R4
hostname R4
interface Loopback0
 ip address 4.4.4.4 255.255.255.255
 ip ospf 1 area 456
!
interface FastEthernet0/0
 ip address 10.1.222.4 255.255.255.0
 ip ospf 1 area 456
 no shutdown
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
 no shutdown
!
interface Serial0/0.42 point-to-point
 bandwidth 128
 ip address 10.1.24.4 255.255.255.0
 snmp trap link-status
 frame-relay interface-dlci 402
!
router bgp 456
 no bgp default ipv4-unicast
 neighbor 5.5.5.5 remote-as 456
 neighbor 5.5.5.5 update-source Loopback0
 neighbor 6.6.6.6 remote-as 456
 neighbor 6.6.6.6 update-source Loopback0
 neighbor 10.1.24.2 remote-as 123
 !
 address-family ipv4
  neighbor 5.5.5.5 activate
  neighbor 5.5.5.5 next-hop-self
  neighbor 6.6.6.6 activate
  neighbor 6.6.6.6 next-hop-self
  neighbor 10.1.24.2 activate
  no auto-summary
  no synchronization
  network 4.4.4.4 mask 255.255.255.255
 exit-address-family
!

R5

hostname R5
interface Loopback0
 ip address 5.5.5.5 255.255.255.255
 ip ospf 1 area 456
!
interface FastEthernet0/0
 ip address 10.1.222.5 255.255.255.0
 ip ospf 1 area 456
 no shutdown
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
 no shutdown
!
interface Serial0/0.53 point-to-point
 bandwidth 192
 ip address 10.1.35.5 255.255.255.0
 snmp trap link-status
 frame-relay interface-dlci 503
!
router bgp 456
 no bgp default ipv4-unicast
 neighbor 4.4.4.4 remote-as 456
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 6.6.6.6 remote-as 456
 neighbor 6.6.6.6 update-source Loopback0
 neighbor 10.1.35.3 remote-as 123
 !
 address-family ipv4
  neighbor 4.4.4.4 activate
  neighbor 4.4.4.4 next-hop-self
  neighbor 6.6.6.6 activate
  neighbor 6.6.6.6 next-hop-self
  neighbor 10.1.35.3 activate
  no auto-summary
  no synchronization
  network 5.5.5.5 mask 255.255.255.255
 exit-address-family
!



R6
hostname R6
interface Loopback0
 ip address 6.6.6.6 255.255.255.255
 ip ospf 1 area 456
!
interface FastEthernet0/0
 ip address 10.1.222.6 255.255.255.0
 ip ospf 1 area 456
 no shutdown
!
router bgp 456
 no bgp default ipv4-unicast
 neighbor 4.4.4.4 remote-as 456
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 5.5.5.5 remote-as 456
 neighbor 5.5.5.5 update-source Loopback0
 !
 address-family ipv4
  neighbor 4.4.4.4 activate
  neighbor 5.5.5.5 activate
  no auto-summary
  no synchronization
  network 6.6.6.6 mask 255.255.255.255
 exit-address-family
!

Lets check the bgp table and routing tables on R1 and R6

R1#sh ip bgp | b Network
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
r>i2.2.2.2/32       2.2.2.2                  0    100      0 i
r>i3.3.3.3/32       3.3.3.3                  0    100      0 i
* i4.4.4.4/32       3.3.3.3                  0    100      0 456 i
*>i                 2.2.2.2                  0    100      0 456 i
*>i5.5.5.5/32       2.2.2.2                  0    100      0 456 i
* i                 3.3.3.3                  0    100      0 456 i
*>i6.6.6.6/32       2.2.2.2                  0    100      0 456 i
* i                 3.3.3.3                  0    100      0 456 i
R1#sh ip route bgp
     4.0.0.0/32 is subnetted, 1 subnets
B       4.4.4.4 [200/0] via 2.2.2.2, 00:03:02
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [200/0] via 2.2.2.2, 00:03:02
     6.0.0.0/32 is subnetted, 1 subnets
B       6.6.6.6 [200/0] via 2.2.2.2, 00:01:03

R6#sh ip bgp | b Network
   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.1/32       4.4.4.4                  0    100      0 123 i
* i                 5.5.5.5                  0    100      0 123 i
*>i2.2.2.2/32       4.4.4.4                  0    100      0 123 i
* i                 5.5.5.5                  0    100      0 123 i
*>i3.3.3.3/32       4.4.4.4                  0    100      0 123 i
* i                 5.5.5.5                  0    100      0 123 i
r>i4.4.4.4/32       4.4.4.4                  0    100      0 i
r>i5.5.5.5/32       5.5.5.5                  0    100      0 i
*> 6.6.6.6/32       0.0.0.0                  0         32768 i
R6#sh ip route bgp
     1.0.0.0/32 is subnetted, 1 subnets
B       1.1.1.1 [200/0] via 4.4.4.4, 00:01:28
     2.0.0.0/32 is subnetted, 1 subnets
B       2.2.2.2 [200/0] via 4.4.4.4, 00:01:28
     3.0.0.0/32 is subnetted, 1 subnets
B       3.3.3.3 [200/0] via 4.4.4.4, 00:01:28

Right now we can see only one BGP route is installed in our routing table because that is the default behaviour.  Right now we are interested in R1 and R6 being able to use the other exit points from their autonomous systems, so lets enable bgp multipath (since R1 and R6 only have ibgp peers we need to enable this for ibgp)

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router bgp 123
R1(config-router)#address-family ipv4
R1(config-router-af)#maximum-paths ibgp 2
R1(config-router-af)#end

R1#sh ip route bgp
     4.0.0.0/32 is subnetted, 1 subnets
B       4.4.4.4 [200/0] via 3.3.3.3, 00:00:30
                [200/0] via 2.2.2.2, 00:04:55
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [200/0] via 3.3.3.3, 00:00:30
                [200/0] via 2.2.2.2, 00:04:55
     6.0.0.0/32 is subnetted, 1 subnets
B       6.6.6.6 [200/0] via 3.3.3.3, 00:00:30
                [200/0] via 2.2.2.2, 00:02:57

R6#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R6(config)#router bgp 456
R6(config-router)#address-family ipv4
R6(config-router-af)#maximum-paths ibgp 2
R6(config-router-af)#end
R6#
R6#sh ip route bgp
     1.0.0.0/32 is subnetted, 1 subnets
B       1.1.1.1 [200/0] via 5.5.5.5, 00:00:06
                [200/0] via 4.4.4.4, 00:03:55
     2.0.0.0/32 is subnetted, 1 subnets
B       2.2.2.2 [200/0] via 5.5.5.5, 00:00:06
                [200/0] via 4.4.4.4, 00:03:55
     3.0.0.0/32 is subnetted, 1 subnets
B       3.3.3.3 [200/0] via 5.5.5.5, 00:00:06
                [200/0] via 4.4.4.4, 00:03:55

Okay, now R1 and R6 are able to utilise both exit points however to get maximum efficiency of these links it would be worthwhile to share the load across the links relatively fairly based on the static link bandwidths.

We do this by:
  1. activating the bgp dmzlink-bw function
  2. Ensuring that we send our extended bgp communities to our IBGP peers
  3. Associate the dmzlink-bw with our EBGP neighbor

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router bgp 123
R2(config-router)#address-family ipv4 unicast
R2(config-router-af)#bgp dmzlink-bw
R2(config-router-af)#neighbor 1.1.1.1 send-community extended
R2(config-router-af)#neighbor 3.3.3.3 send-community extended
R2(config-router-af)#neighbor 10.1.24.4 dmzlink-bw
R2(config-router-af)#end

R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router bgp 123
R3(config-router)#address-family ipv4 unicast
R3(config-router-af)#bgp dmzlink-bw
R3(config-router-af)#neighbor 1.1.1.1 send-community extended
R3(config-router-af)#neighbor 2.2.2.2 send-community extended
R3(config-router-af)#neighbor 10.1.35.5 dmzlink-bw
R3(config-router-af)#end

R1#sh ip bgp 6.6.6.6
BGP routing table entry for 6.6.6.6/32, version 16
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Multipath: iBGP
Flag: 0x8820
  Not advertised to any peer
  456
    3.3.3.3 (metric 11) from 3.3.3.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, internal, multipath
      DMZ-Link Bw 24 kbytes
  456
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, multipath, best
      DMZ-Link Bw 16 kbytes


R1#sh ip route 6.6.6.6
Routing entry for 6.6.6.6/32
  Known via "bgp 123", distance 200, metric 0
  Tag 456, type internal
  Last update from 2.2.2.2 00:00:05 ago
  Routing Descriptor Blocks:
  * 3.3.3.3, from 3.3.3.3, 00:00:05 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 456
    2.2.2.2, from 2.2.2.2, 00:00:05 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 456

We can see that the dmz-linkbw community is being received by R1 but it's not doing anything with it...

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router bgp 123
R1(config-router)#address-family ipv4 unicast
R1(config-router-af)#bgp dmzlink-bw
R1(config-router-af)#end

Now to bounce our BGP peering

R1#clear ip bgp *
R1#
*Mar  1 00:33:47.999: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down User reset
*Mar  1 00:33:47.999: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Down User reset
*Mar  1 00:34:18.059: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up
*Mar  1 00:34:18.063: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up
R1#sh ip route 6.6.6.6
Routing entry for 6.6.6.6/32
  Known via "bgp 123", distance 200, metric 0
  Tag 456, type internal
  Last update from 2.2.2.2 00:00:05 ago
  Routing Descriptor Blocks:
  * 3.3.3.3, from 3.3.3.3, 00:00:05 ago
      Route metric is 0, traffic share count is 2
      AS Hops 1
      Route tag 456
    2.2.2.2, from 2.2.2.2, 00:00:05 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 456

That's more like it

Let's do the equivalent for our routers in AS 456

R4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#router bgp 456
R4(config-router)#address-family ipv4 unicast
R4(config-router-af)#bgp dmzlink-bw
R4(config-router-af)#neighbor 5.5.5.5 send-community extended
R4(config-router-af)#neighbor 6.6.6.6 send-community extended
R4(config-router-af)#neighbor 10.1.24.2 dmzlink-bw
R4(config-router-af)#end


R5#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R5(config)#router bgp 456
R5(config-router)#address-family ipv4 unicast
R5(config-router-af)#bgp dmzlink-bw
R5(config-router-af)#neighbor 4.4.4.4 send-community extended
R5(config-router-af)#neighbor 6.6.6.6 send-community extended
R5(config-router-af)#neighbor 10.1.35.3 dmzlink-bw
R5(config-router-af)#end


R6#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R6(config)#router bgp 456
R6(config-router)#address-family ipv4 unicast
R6(config-router-af)#bgp dmzlink-bw
R6(config-router-af)#end

R6#clear ip bgp *
R6#
*Mar  1 00:49:11.923: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Down User reset
*Mar  1 00:49:11.927: %BGP-5-ADJCHANGE: neighbor 5.5.5.5 Down User reset
*Mar  1 00:49:25.943: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Up
*Mar  1 00:49:25.947: %BGP-5-ADJCHANGE: neighbor 5.5.5.5 Up
R6#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 10
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Multipath: iBGP
Flag: 0x8820
  Not advertised to any peer
  123
    5.5.5.5 (metric 11) from 5.5.5.5 (5.5.5.5)
      Origin IGP, metric 0, localpref 100, valid, internal, multipath
      DMZ-Link Bw 24 kbytes
  123
    4.4.4.4 (metric 11) from 4.4.4.4 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, internal, multipath, best
      DMZ-Link Bw 16 kbytes

R6#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
  Known via "bgp 456", distance 200, metric 0
  Tag 123, type internal
  Last update from 4.4.4.4 00:00:43 ago
  Routing Descriptor Blocks:
  * 5.5.5.5, from 5.5.5.5, 00:00:43 ago
      Route metric is 0, traffic share count is 2
      AS Hops 1
      Route tag 123
    4.4.4.4, from 4.4.4.4, 00:00:43 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 123

Let's set up some basic metering using cbqos and test if load balancing works

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#policy-map TST
R2(config-pmap)#class class-default
R2(config-pmap-c)#int s0/0.24
R2(config-subif)#service-policy input TST
R2(config-subif)#service-policy output TST
R2(config-subif)#int s0/0
R2(config-if)#load-interval 30
R2(config-if)#end

R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#policy-map TST
R3(config-pmap)#class class-default
R3(config-pmap-c)#int s0/0.35
R3(config-subif)#service-policy input TST
R3(config-subif)#service-policy output TST
R3(config-subif)#int s0/0
R3(config-if)#load-interval 30
R3(config-if)#end

Now we will do an extended ping between R1 Lo0 and R6 Lo0, we'll use the record route option so we can see that the path doesn't remain the same for all of the pings.

R1#ping
Protocol [ip]:
Target IP address: 6.6.6.6
Repeat count [5]: 1000
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 1.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]: r
Number of hops [ 9 ]: 8
Loose, Strict, Record, Timestamp, Verbose[RV]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
Packet has IP options:  Total option bytes= 39, padded length=40
 Record route: <*>
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)

Reply to request 0 (20 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

Reply to request 1 (8 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

Reply to request 2 (12 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.24.2)
   (10.1.222.4)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.24.4)
   (10.1.111.2)
   (1.1.1.1)
   <*>
 End of list

Reply to request 3 (8 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

Reply to request 4 (16 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

..............
 
Reply to request 997 (8 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

Reply to request 998 (8 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.24.2)
   (10.1.222.4)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.24.4)
   (10.1.111.2)
   (1.1.1.1)
   <*>
 End of list

Reply to request 999 (12 ms).  Received packet has options
 Total option bytes= 36, padded length=36
 Record route:
   (10.1.111.1)
   (10.1.35.3)
   (10.1.222.5)
   (6.6.6.6)
   (10.1.222.6)
   (10.1.35.5)
   (10.1.111.3)
   (1.1.1.1)
   <*>
 End of list

Success rate is 100 percent (1000/1000), round-trip min/avg/max = 1/10/20 ms




We can see that the path alternates somewhat in a pattern that looks close to 2:1 but lets check it by looking at the traffic counters

R2#sh policy-map int s0/0.24

 Serial0/0.24

  Service-policy input: TST

    Class-map: class-default (match-any)
      335 packets, 34739 bytes
      30 second offered rate 8000 bps, drop rate 0 bps
      Match: any

  Service-policy output: TST

    Class-map: class-default (match-any)
      335 packets, 38351 bytes
      30 second offered rate 9000 bps, drop rate 0 bps
      Match: any

R3#sh policy-map int s0/0.35

 Serial0/0.35

  Service-policy input: TST

    Class-map: class-default (match-any)
      668 packets, 69431 bytes
      30 second offered rate 12000 bps, drop rate 0 bps
      Match: any

  Service-policy output: TST

    Class-map: class-default (match-any)
      670 packets, 76471 bytes
      30 second offered rate 13000 bps, drop rate 0 bps
      Match: any

The packet load appears to pretty much align with the traffic share count.

Sunday, 27 May 2012

IOS Based traffic generation with tcp-small-servers

Recently I was watching the INE vSeminar on OER - 7.5 hours of well I wouldn't exactly call it joy but it is certainly enlightening on how the performance routing (the current name for optimized edge routing) "works" in an IOS 12.4(15)T environment.   The version number is of relevance as that is currently what the CCIE Lab uses, however based on my own experiences and seeing the vSeminar, while quite powerful and flexible, it is also kind of fragile while you try to develop your configuration.

Anyway one of the interesting things that came out of it wasn't directly related to OER itself except that it needed some traffic flows to take actions upon and rather than purely using on pings, Brian demoed a different technique that used TCP traffic flows by enable "service tcp-small-servers" on the router you would like to generate the traffic from, and telneting on port 19 from where you would like the traffic sent.


Here's a quick demo with two routers:

R1
hostname R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
!
interface Serial0/0.12 point-to-point
 description R2 S0/0.21
 ip address 10.1.12.1 255.255.255.0
 frame-relay interface-dlci 102
!
router ospf 1
 log-adjacency-changes
 network 1.1.1.1 0.0.0.0 area 0
 network 10.1.12.1 0.0.0.0 area 0
!

R2
hostname R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Serial0/0
 no ip address
 encapsulation frame-relay
 no frame-relay inverse-arp
!
interface Serial0/0.21 point-to-point
 description R1 S0/0.12
 ip address 10.1.12.2 255.255.255.0
 frame-relay interface-dlci 201
!
router ospf 1
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 10.1.12.2 0.0.0.0 area 0
!

First lets verify connectivity:

R2#ping 1.1.1.1 source 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

Enabling tcp-small-servers enables the chargen service on TCP Port 19.  Other services such as echo, discard and daytime are enabled but aren't so helpful when it comes to traffic generation.


R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#service tcp-small-servers

We cant see it but the router is listening to TCP Port 19

R1(config)#do sh tcp brief all
TCB       Local Address               Foreign Address             (state)
674596C8  *.80                        *.*                         LISTEN
 

R2#telnet 1.1.1.1 chargen /source-interface lo0
Trying 1.1.1.1, 19 ... Open
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh
"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij
.....

The output on R2 is the chargen service on R1 which will run forever (or at least the session is closed) On R1 we can see the session is up and running.

R1(config)#do sh tcp brief all
TCB       Local Address               Foreign Address             (state)
665DEFFC  1.1.1.1.19                  2.2.2.2.20844               ESTAB
674596C8  *.80                        *.*                         LISTEN

Lets see how fast R1 is pushing out traffic

R1(config)#policy-map Monitor
R1(config-pmap)#class class-default
R1(config)#int s0/0.12
R1(config-subif)#service-policy output Monitor
R1(config-subif)#int s0/0
R1(config-if)#load-interval 30

We wait for a short period and see how fast R1 is going

R1(config-if)#do sh policy-map int s0/0.12 out

 Serial0/0.12

  Service-policy output: Monitor

    Class-map: class-default (match-any)
      10441 packets, 1232016 bytes
      30 second offered rate 56000 bps, drop rate 0 bps
      Match: any

Lets shape the outbound TCP traffic to 32kbps


R1(config)#ip access-list extended TCP
R1(config-ext-nacl)#permit tcp any any
R1(config-ext-nacl)#class TCP
R1(config-cmap)#match access-group name TCP
R1(config-cmap)#policy-map SHAPE_TCP
R1(config-pmap)#class TCP
R1(config-pmap-c)#shape average 32000
R1(config)#int s0/0.12
R1(config-subif)#no service-policy output Monitor
R1(config-subif)#service-policy output SHAPE_TCP

And leave things for a minute or so to see how things are operating

R1(config-subif)#do sh policy-map int s0/0.12 out

 Serial0/0.12

  Service-policy output: SHAPE_TCP

    Class-map: TCP (match-all)
      3810 packets, 449510 bytes
      30 second offered rate 32000 bps, drop rate 0 bps
      Match: access-group name TCP
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
            32000/32000     2000   8000      8000      250       1000

        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      26        3784      446442    3740      441320    yes

    Class-map: class-default (match-any)
      28 packets, 3320 bytes
      30 second offered rate 0 bps, drop rate 0 bps
      Match: any

TCP is adapting to the link bandwidth giving us a 32kbps stream we can play with elsewhere in our network.


If for whatever reason we found that the typical telnet escape sequence (Control+Shift+6 x) didn't work on R2, we can close the session from R1

R1(config)#do sh tcp brief all
TCB       Local Address               Foreign Address             (state)
665DEFFC  1.1.1.1.19                  2.2.2.2.20844               ESTAB
674596C8  *.80                        *.*                         LISTEN
R1(config-if)#do clear tcp local 1.1.1.1 19 remote 2.2.2.2 20844
[confirm]
 [OK]
R1(config-subif)#do sh tcp br all
TCB       Local Address               Foreign Address             (state)
674596C8  *.80                        *.*                         LISTEN

Probably not something useful for the CCIE Lab itself but for testing QoS in your own environment it may be useful.

Monday, 21 May 2012

Back to Basics

As part of my getting back to basics regime I've been going through Narbik's Advanced Routing and Switching 4.0 Workbooks.To be honest it's not basics but it's refreshing to go back to something as simple as Ethernet trunking (honestly DTP isn't something I haven't given a lot of thought to in awhile and while there was nothing earth shattering, it's good to touch base again) and incrementally re-enforce my knowledge.

One of my old favourite commands that I've been using recently is "show ip protocols" which gives such a wealth of information including timers, authentication key usage and if protocols are being redistributed.

Last night I went through a rather epic RIP lab that touched 9 routers, and now it's time to jump into EIGRP...

Saturday, 12 May 2012

Switch Port Authentication with 802.1x

Lately I have been playing around with FreeRADIUS and thought it may be interesting to play around with dot1x on switch ports.

The topology I'm using today uses a AAA server, two routers and a switch:

(AAA)eth0---Fa1/0(R1)Fa0/0--Trunk--Fa1/0/1(SW1)Fa1/0/14---Fa1/0(R2)


The link between R1 and SW1 is using a trunk to support multiple VLANs.  VLAN 11 is used for AAA/SW1 connectivity and VLAN 12 for R1/R2 connectivity.


R2 is acting as our end device and is a DHCP client

Thanks to bridging on R1, AAA (192.168.100.253/24), R1 (BVI1 = 192.168.100.1/24)and SW1(VLAN11 = 192.168.100.11/24) are all on the same subnet



Here are our configurations:

R1
hostname R1
bridge irb
bridge 1 protocol ieee
bridge 1 route ip
ip dhcp excluded-address 10.1.12.1
ip dhcp excluded-address 10.1.12.3 10.1.12.254
ip dhcp pool R2
   network 10.1.12.0 255.255.255.0
!
interface FastEthernet0/0
 description SW1 Fa1/0/1
 no ip address
!
interface FastEthernet0/0.11
 description For SW1 to Communicate with AAA
 encapsulation dot1Q 11
 bridge-group 1
!
interface FastEthernet0/0.12
 description To Communicate with R1
 encapsulation dot1Q 12
 ip address 10.1.12.1 255.255.255.0
!
interface FastEthernet1/0
 description To AAA
 no ip address
 bridge-group 1
!

SW1
hostname SW1
aaa new-model
aaa authentication dot1x default group radius
aaa authorization network default group radius
dot1x system-auth-control
vlan 11-12,99
ip dhcp excluded-address 99.99.99.99
ip dhcp pool GuestVLAN
   network 99.99.99.0 255.255.255.0
!
!
interface FastEthernet1/0/1
 description R1 Fa0/0
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet1/0/14
 description R2 Fa1/0
 switchport mode access
 dot1x pae authenticator
 dot1x port-control auto
 dot1x violation-mode protect
 dot1x guest-vlan 99
 spanning-tree portfast
 shutdown
!
interface Vlan11
 ip address 192.168.100.11 255.255.255.0
!
interface Vlan99
 ip address 99.99.99.99 255.255.255.0
!
radius-server host 192.168.100.253 auth-port 1812 acct-port 1813 key cisco


R2
hostname R2
interface FastEthernet1/0
 description SW1 Fa1/0/14
 ip address dhcp
!

The freeradius configuration is stock standard except for the two files below:
radius-server:~# cat /etc/freeradius/clients.conf
client 192.168.100.0/24 {
        secret=cisco
        shortname=router
}

radius-server:~# cat /etc/freeradius/users
R2      Cleartext-Password := "R2"
        Tunnel-Type = VLAN,
        Tunnel-Medium-Type = IEEE-802,
        Tunnel-Private-Group-ID = 12

Initially R2 has no configuration associated with dot1x on it.  SW1 is set to communicate with the free-radius server to verify the end device connecting on Fa1/0/14.
  1. If the end device does not appear to be a dot1x client (supplicant) then after several attempts of seeing if the end device really doesn't support dot1x, the switch will place the user into the guest vlan
  2. If the end device supports dot1x and authentication fails, the user will not be allowed on the network.
  3. If the end device supports dot1x and authentication succeeds, the AAA will pass back what VLAN the user should be associated with and the switch will put the user into it
The current configuration is set up for #1

Let's start things going

SW1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
SW1(config)#int fa1/0/14
SW1(config-if)#no shut
*Mar  1 09:04:43.416: %LINK-3-UPDOWN: Interface FastEthernet1/0/14, changed state to up
SW1(config-if)#do show dot1x int fa1/0/14 detail

Dot1x Info for FastEthernet1/0/14
-----------------------------------
PAE                       = AUTHENTICATOR
PortControl               = AUTO
ControlDirection          = Both
HostMode                  = SINGLE_HOST
Violation Mode            = PROTECT
ReAuthentication          = Disabled
QuietPeriod               = 60
ServerTimeout             = 0
SuppTimeout               = 30
ReAuthPeriod              = 3600 (Locally configured)
ReAuthMax                 = 2
MaxReq                    = 2
TxPeriod                  = 30
RateLimitPeriod           = 0
Guest-Vlan                = 99

Dot1x Authenticator Client List Empty

Domain                    = DATA
Port Status               = UNAUTHORIZED





Right now SW1 Fa1/0/14 is sending out EAPOL frames and waiting for a response from a supplicant.  After about 90 seconds, the switch will have decided that there isn't a supplicant on the end and to push the end device into the Guest-VLAN

*Mar  1 09:06:16.949: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0/14, changed state to up




R2#
*Mar  1 02:32:41.847: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet1/0 assigned DHCP address 99.99.99.3, mask 255.255.255.0, hostname R2

We can see that R2 was assigned an IP by SW1 from the GuestVLAN DHCP pool we defined earlier, and we can see that Port Fa1/0/14 was put into VLAN 99 because that is the guest vlan that we configured earlier.
 
SW1(config-if)#do sh interfaces fa1/0/14 switchport | i ^Name|^Operational Mode|^Access Mode
Name: Fa1/0/14
Operational Mode: static access
Access Mode VLAN: 99 (VLAN0099)


SW1(config-if)#do sh dot1x int fa1/0/14 details

Dot1x Info for FastEthernet1/0/14
-----------------------------------
PAE                       = AUTHENTICATOR
PortControl               = AUTO
ControlDirection          = Both
HostMode                  = SINGLE_HOST
Violation Mode            = PROTECT
ReAuthentication          = Disabled
QuietPeriod               = 60
ServerTimeout             = 0
SuppTimeout               = 30
ReAuthPeriod              = 3600 (Locally configured)
ReAuthMax                 = 2
MaxReq                    = 2
TxPeriod                  = 30
RateLimitPeriod           = 0
Guest-Vlan                = 99

Dot1x Authenticator Client List Empty

Domain                    = DATA
Port Status               = AUTHORIZED

Authorized By             = Guest-Vlan
Operational HostMode      = MULTI_HOST
Vlan Policy               = 99

For setup #2 lets turn R2 into a 802.1x supplicant - firstly we shall configure our credentials:

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#dot1x credentials R2
R2(config-dot1x-creden)#username R2
R2(config-dot1x-creden)#password r3



now we change our function to act as a dot1x supplicant and attach the credentials for the interface

R2(config-dot1x-creden)#int fa1/0
R2(config-if)#dot1x pae supplicant
R2(config-if)#dot1x credentials R2
R2(config-if)#end

Hmm, as soon as we do this, SW1 pulls down the line protocol and tried to authenticate our supplicant

SW1#*Mar  1 09:20:03.026: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0/14, changed state to down


SW1#show dot1x interface fa1/0/14 de

Dot1x Info for FastEthernet1/0/14
-----------------------------------
PAE                       = AUTHENTICATOR
PortControl               = AUTO
ControlDirection          = Both
HostMode                  = SINGLE_HOST
Violation Mode            = PROTECT
ReAuthentication          = Disabled
QuietPeriod               = 60
ServerTimeout             = 0
SuppTimeout               = 30
ReAuthPeriod              = 3600 (Locally configured)
ReAuthMax                 = 2
MaxReq                    = 2
TxPeriod                  = 30
RateLimitPeriod           = 0
Guest-Vlan                = 99

Dot1x Authenticator Client List
-------------------------------
Domain                    = DATA
Supplicant                = c201.08b9.0010

    Auth SM State         = HELD
    Auth BEND SM State    = IDLE
Port Status               = UNAUTHORIZED
Authentication Method     = Dot1x

let's see what is happening by debugging dot1x events on SW1

SW1#deb dot1x events
Dot1x events debugging is on
*Mar  1 09:31:13.871: dot1x-ev:Sending create new context event to EAP for c201.08b9.0010
*Mar  1 09:31:13.871: dot1x-ev:FastEthernet1/0/14:Sending EAPOL packet to group PAE address
*Mar  1 09:31:13.871: dot1x-ev:dot1x_mgr_pre_process_eapol_pak: Role determination not required on FastEthernet1/0/14.
*Mar  1 09:31:13.871: dot1x-ev:dot1x_mgr_send_eapol: Sending out EAPOL packet on FastEthernet1/0/14
*Mar  1 09:31:13.879: dot1x-ev:dot1x_mgr_pre_process_eapol_pak: Role determination not required on FastEthernet1/0/14.
*Mar  1 09:31:13.879: dot1x-ev:Enqueued the eapol packet to the global authenticator queue
*Mar  1 09:31:13.879: EAPOL pak dump rx
*Mar  1 09:31:13.879: EAPOL Version: 0x2  type: 0x0  length: 0x0007
*Mar  1 09:31:13.879: dot1x-ev:
dot1x_auth_queue_event: Int Fa1/0/14 CODE= 2,TYPE= 1,LEN= 7

*Mar  1 09:31:13.879: dot1x-ev:Received pkt saddr =c201.08b9.0010 , daddr = 0180.c200.0003,
                    pae-ether-type = 888e.0200.0007
*Mar  1 09:31:13.879: dot1x-ev:dot1x_auth_process_eapol: EAPOL flag status of the port  Fa1/0/14 is TRUE

*Mar  1 09:31:13.879: dot1x-ev:dot1x_sendRespToServer: Response sent to the server from c201.08b9.0010
*Mar  1 09:31:13.930: dot1x-ev:FastEthernet1/0/14:Sending EAPOL packet to group PAE address
*Mar  1 09:31:13.930: dot1x-ev:dot1x_mgr_pre_process_eapol_pak: Role determination not required on FastEthernet1/0/14.
*Mar  1 09:31:13.930: dot1x-ev:dot1x_mgr_send_eapol: Sending out EAPOL packet on FastEthernet1/0/14
*Mar  1 09:31:13.938: dot1x-ev:dot1x_mgr_pre_process_eapol_pak: Role determination not required on FastEthernet1/0/14.
*Mar  1 09:31:13.938: dot1x-ev:Enqueued the eapol packet to the global authenticator queue
*Mar  1 09:31:13.938: EAPOL pak dump rx
*Mar  1 09:31:13.938: EAPOL Version: 0x2  type: 0x0  length: 0x0016
*Mar  1 09:31:13.938: dot1x-ev:
dot1x_auth_queue_event: Int Fa1/0/14 CODE= 2,TYPE= 4,LEN= 22

*Mar  1 09:31:13.938: dot1x-ev:Received pkt saddr =c201.08b9.0010 , daddr = 0180.c200.0003,
                    pae-ether-type = 888e.0200.0016
*Mar  1 09:31:13.938: dot1x-ev:dot1x_auth_process_eapol: EAPOL flag status of the port  Fa1/0/14 is TRUE

*Mar  1 09:31:13.938: dot1x-ev:dot1x_sendRespToServer: Response sent to the server from c201.08b9.0010
*Mar  1 09:31:14.962: dot1x-ev:Authorization data for client c201.08b9.0010 has been reset on FastEthernet1/0/14
*Mar  1 09:31:14.962: dot1x-ev:Received an EAP Fail on FastEthernet1/0/14 for mac c201.08b9.0010
*Mar  1 09:31:14.962: dot1x-ev:dot1x_switch_authz_fail: Called for FastEthernet1/0/14 and c201.08b9.0010
*Mar  1 09:31:14.962: dot1x-ev:dot1x_switch_port_unauthorized: Unauthorizing interface FastEthernet1/0/14
*Mar  1 09:31:14.962: dot1x-ev:dot1x_switch_is_dot1x_forwarding_enabled: Forwarding is disabled on Fa1/0/14
*Mar  1 09:31:14.962: dot1x-ev:dot1x_switch_addr_remove: Did not locate HA entry for MAC c201.08b9.0010 on interface FastEthernet1/0/14
*Mar  1 09:31:14.962: dot1x-ev:dot1x_vlan_assign_authz_fail on interface FastEthernet1/0/14
*Mar  1 09:31:14.962: dot1x-ev:FastEthernet1/0/14:Sending EAPOL packet to group PAE address
*Mar  1 09:31:14.962: dot1x-ev:dot1x_mgr_pre_process_eapol_pak: Role determination not required on FastEthernet1/0/14.
*Mar  1 09:31:14.962: dot1x-ev:dot1x_mgr_send_eapol: Sending out EAPOL packet on FastEthernet1/0/14

If we look at the highlighted section above we can see that our dot1x authorization has failed - this is quite probably because authentication has not succeeded.

R2#sh run | s ^dot1x
dot1x credentials R2
 username R2
 password 0 r3

Okay, this is due to our password being incorrect, it's a simple fix, we can see what is required by looking at what was configured in the users file for freeradius and bounce the interface.

Repairing this will give us setup #3

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#dot1x credentials R2
R2(config-dot1x-creden)#password R2
R2(config-dot1x-creden)#int fa1/0
R2(config-if)#shut
R2(config-if)#no shut
R2(config-if)#end
R2#
*Mar  1 03:36:29.863: %SYS-5-CONFIG_I: Configured from console by console
*Mar  1 03:36:32.299: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet1/0 assigned DHCP address 10.1.12.2, mask 255.255.255.0, hostname R2




An IP address allocated by R1 certainly indicates that things are now working as desired.

SW1#sh interfaces fa1/0/14 switchport | ^Name|^Operational Mode|^Access ModeName: Fa1/0/14
Operational Mode: static access
Access Mode VLAN: 12 (VLAN0012)
SW1#show dot1x int fa1/0/14 det | b Client List

Dot1x Authenticator Client List
-------------------------------
Domain                    = DATA
Supplicant                = c201.08b9.0010
    Auth SM State         = AUTHENTICATED
    Auth BEND SM State    = IDLE
Port Status               = AUTHORIZED
Authentication Method     = Dot1x
Authorized By             = Authentication Server
Vlan Policy               = 12

We can see that R2 is authorized by our AAA server and the port was pushed into VLAN 12.

R2#ping 10.1.12.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.12.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 4/8/20 ms

There are more things that can be done, however should serve as a reasonable introduction into using dot1x.