Este documento descreve os miniaplicativos Embedded Event Manager (EEM) usados em redes onde o Performance Routing (PfR) otimiza o tráfego através de vários Border Relays (BRs). Alguns loops de encaminhamento também são observados. Os applets são usados para coletar dados quando um loop é observado e mitigar o impacto de um loop de encaminhamento.
Não existem requisitos específicos para este documento.
As informações neste documento são baseadas no software Cisco IOS® que suporta a versão 4.0 do EEM.
Para verificar a versão EEM suportada pela sua versão do Cisco IOS, use este comando:
Router#sh event manager version | i Embedded
Embedded Event Manager Version 4.00
Router#
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.
Quando o PfR controla uma classe de tráfego (TC), ele cria um mapa de rota dinâmica/lista de controle de acesso (ACL) nos BRs. O mapa de rotas em um BR com uma saída selecionada aponta para uma saída selecionada, enquanto um mapa de rotas em outros BRs aponta para uma interface interna (próximo salto = BR selecionado).
Um problema ocorre quando as ACLs dinâmicas não são sincronizadas corretamente entre as diferentes BRs (devido a bugs, por exemplo).
Nesta figura, o foco é no TC que corresponde a todos os pacotes IP destinados a 172.16.1.0/24 com DSCP EF. Neste cenário, a entrada da ACL relacionada é removida do BR selecionado (BR-2), mas não do BR-1. Os pacotes desse TC chegaram no BR-2 com a entrada de prefixo que corresponde a todos os pacotes IP destinados a 172.16.1.0/24. A saída selecionada para a entrada do prefixo é Exit-1, portanto, o mapa de rota/ACL relacionado em BR-2 aponta para BR-1.
Os pacotes desse TC agora fazem loop entre os BRs até que o Time To Live (TTL) atinja 0.
Este documento fornece os miniaplicativos EEM necessários usados para:
Os miniaplicativos usados no caso de uma combinação de controlador mestre (MC)/BR são muito mais fáceis (quando a MC é executada em um dos BRs). O cenário com MCs dedicados também é abordado.
Esta seção descreve as listas de acesso usadas para esse processo, bem como os arquivos de registro de miniaplicativos.
Para detectar loops de encaminhamento, o applet depende de uma ACL para corresponder pacotes com TTL baixo.
Recomenda-se usar a correspondência de ACE em valores de TTL 2 vezes consecutivos, relativamente baixos (20 e 21) para obter um acerto (e apenas um) para cada pacote que faz loops entre BRs. O valor TTL usado não deve ser muito baixo para evitar acertos frequentes de pacotes traceroute.
interface gig0/0 (internal interface)
ip access-group LOOP in
!
ip access-list extended LOOP
permit ip 10.116.48.0 0.0.31.255 any ttl range 20 21
permit ip any any
A ACL deve ser colocada na interface interna informada na saída do comando show pfr master border topology.
O intervalo de IP origem (aqui 10.116.48.0/20) deve corresponder às redes internas (prefixos alcançáveis através de interfaces internas).
Para identificar qual local remoto/TC é afetado pelo loop, você pode adicionar uma segunda saída da ACL na interface, com ACEs mais específicas para cada local remoto/TC.
interface gig0/0 (internal interface)
ip access-group LOOP-DETAIL out
!
ip access-list extended LOOP-DETAIL
permit ip 10.116.48.0 0.0.31.255 10.116.132.0 0.0.0.255 ttl range 20 21
permit ip 10.116.48.0 0.0.31.255 10.116.128.0 0.0.0.255 ttl range 20 21
.... (add here one line per remote site)
permit ip any an
O IP de destino corresponde à sub-rede em diferentes locais remotos:
10.116.132.0/24 -> site-1
10.116.128.0/24 -> site-2
Você também pode adicionar várias linhas por local remoto se precisar identificar o TC exato afetado pelo loop.
O applet verifica as contagens de ocorrências da ACE correspondente no TTL no loop da ACL a cada trinta segundos. Com base no resultado dessas verificações, o applet pode executar estas tarefas:
O applet mantém um arquivo de log que controla o número de contagens de ocorrências (quando a contagem é maior que 0) e quaisquer encontros de loops temporários (quando THRESHOLD_1 é excedido, mas não THRESHOLD_2) ou um loop real (quando THRESHOLD_1 e THRESHOLD_2 são excedidos).
Estes são os cenários mais simples descritos neste documento. A detecção de loop e a limpeza de PfR são feitas no mesmo dispositivo, portanto, não há necessidade de entrar na comunicação de applet de EEM do dispositivo. Um applet separado é executado em um combo MC/BR e em outros BRs.
Esta saída exibe informações importantes para o miniaplicativo usado na combinação MC/BR. Aqui estão algumas notas importantes para esta saída específica:
event manager environment THRESHOLD_1 1000
event manager environment THRESHOLD_2 500
event manager environment DISK bootflash
!
event manager applet LOOP-MON authorization bypass
event timer watchdog name LOOP time 30
action 100 cli command "enable"
action 110 cli command "show ip access-list LOOP"
action 120 set regexp_substr 0
action 130 regexp "range 20 21 \(([0-9]+) matches\)"
$_cli_result _regexp_result regexp_substr
action 140 cli command "clear ip access-list counters LOOP"
action 150 if $regexp_substr gt 0
action 200 set MATCHES $regexp_substr
action 210 file open LOGS $DISK:script-logs.txt a
action 220 cli command "enable"
action 230 cli command "show clock"
action 240 regexp "[0-9]+:[0-9]+:[0-9]+.[0-9]+ est [A-Za-z]+
[A-Za-z]+ [0-9]+ 201[0-9]" $_cli_result _regexp_result
action 250 set TIME $_regexp_result
action 260 if $MATCHES gt $THRESHOLD_1
action 270 wait 15
action 280 cli command "show ip access-list LOOP"
action 290 set regexp_substr 0
action 300 regexp "range 20 21 \(([0-9]+) matches\)"
$_cli_result _regexp_result regexp_substr
action 310 if $regexp_substr gt $THRESHOLD_2
action 320 cli command "enable"
action 330 cli command "show ip access-list LOOP-DETAIL
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 340 cli command "show pfr master traffic-class perf det
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 350 cli command "show route-map dynamic detail
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 360 cli command "show ip route
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 370 cli command "clear pfr master *"
action 380 cli command "clear ip access-list counters LOOP-DETAIL"
action 390 file puts LOGS "$TIME - LOOP DETECTED - PfR CLEARED -
matches $MATCHES > $THRESHOLD_1 and $regexp_substr
> $THRESHOLD_2 - see $DISK:script-output-$_event_pub_sec.txt"
action 400 syslog priority emergencies msg "LOOP DETECTED -
PfR CLEARED - see $DISK:script-output-$_event_pub_sec.txt !"
action 410 else
action 420 file puts LOGS "$TIME - TEMPORARY LOOP : matches
$MATCHES > $THRESHOLD_1 and $regexp_substr < or = $THRESHOLD_2"
action 430 cli command "clear ip access-list counters LOOP-DETAIL"
action 440 end
action 450 else
action 460 cli command "en"
action 470 cli command "clear ip access-list counters LOOP-DETAIL"
action 480 file puts LOGS "$TIME - number of matches =
$MATCHES < $THRESHOLD_1"
action 490 end
action 500 else
action 510 cli command "clear ip access-list counters LOOP-DETAIL"
action 520 end
Esta seção descreve o applet usado para outros BRs. Aqui estão algumas notas importantes para esta saída específica:
event manager environment THRESHOLD 700
event manager environment DISK flash 0
!
event manager applet LOOP-BR authorization bypass
event timer watchdog name LOOP time 20
action 100 cli command "enable"
action 110 cli command "show ip access-list LOOP"
action 120 set regexp_substr 0
action 130 regexp "range 20 21 \(([0-9]+) matches\)"
$_cli_result _regexp_result regexp_substr
action 140 cli command "clear ip access-list counters LOOP"
action 150 if $regexp_substr gt 0
action 160 set MATCHES $regexp_substr
action 170 file open LOGS $DISK:script-logs.txt a
action 180 cli command "show clock"
action 190 regexp "[0-9]+:[0-9]+:[0-9]+.[0-9]+
est [A-Za-z]+ [A-Za-z]+ [0-9]+ 201[0-9]" $_cli_result _regexp_result
action 200 set TIME $_regexp_result
action 210 if $MATCHES gt $THRESHOLD
action 220 cli command "enable"
action 230 cli command "show route-map dynamic detail | tee /append
$DISK:script-output-$_event_pub_sec.txt"
action 240 cli command "show ip route | tee /append
$DISK:script-output-$_event_pub_sec.txt"
action 250 file puts LOGS "$TIME : matches = $MATCHES >
$THRESHOLD - see $DISK:script-output-$_event_pub_sec.txt"
action 260 syslog priority emergencies msg "LOOP DETECTED -
Outputs captured - see $DISK:script-output-$_event_pub_sec.txt !"
action 270 else
action 280 file puts LOGS "$TIME : matches = $MATCHES < or = $THRESHOLD"
action 290 end
action 300 end
A detecção de loop e a limpeza/coleta de estatísticas de PfR são concluídas em dispositivos diferentes que devem ter comunicação de applet de EEM entre dispositivos. A comunicação entre os dispositivos ocorre de maneiras diferentes. Este documento descreve a comunicação do dispositivo através de objetos rastreados para verificar a acessibilidade de loopbacks dedicados anunciados no IGP. Quando um evento é detectado, o loopback é desligado, o que permite que os applets em dispositivos remotos sejam iniciados quando o objeto rastreado fica off-line. Você pode usar loopbacks diferentes se diferentes informações precisarem ser trocadas.
Esses miniaplicativos e métodos de comunicação são usados:
Nome do miniaplicativo | Where? | O quê? | Disparador? | Comunicação? |
LOOP-BR | BRs | Verifique as contagens de ocorrências da ACL para detectar loops |
Periódico | shut Loop100 |
LOOP-MC | MC | - Coletar infos de PfR - Limpa o PfR |
Rastrear loop de acessibilidade100 | shut Loop200 |
COLLECT-BR | BRs | Coletar informações | Rastrear loop de alcançabilidade200 | nenhum |
Aqui está uma imagem que ilustra isto:
Este é o processo usado pelos miniaplicativos:
Esta seção descreve como criar loopbacks (garantir que os IPs sejam anunciados no IGP) e rastrear objetos.
Aqui estão alguns pontos importantes a serem lembrados ao criar objetos de controle:
BR-1
interface Loopback100
ip address 10.100.100.1 255.255.255.255
!
track timer ip route 1
track 1 ip route 10.100.100.200 255.255.255.255 reachability
BR-2
interface Loopback100
ip address 10.100.100.2 255.255.255.255
!
track timer ip route 1
track 1 ip route 10.100.100.200 255.255.255.255 reachability
MC
interface Loopback200
ip address 10.100.100.200 255.255.255.255
!
track timer ip route 1
track 1 ip route 10.100.100.1 255.255.255.255 reachability
track 2 ip route 10.100.100.2 255.255.255.255 reachability
track 11 ip route 10.116.100.1 255.255.255.255 reachability
track 12 ip route 10.116.100.2 255.255.255.255 reachability
track 20 list boolean and
object 11
object 12
LOOP-BR
Esta seção descreve como criar loopbacks nos BRs. Aqui estão algumas notas importantes que devem ser lembradas:
event manager environment THRESHOLD_1 100event manager environment
THRESHOLD_2 500event manager environment DISK bootflash
!event manager applet LOOP-BR authorization bypass
event timer watchdog name LOOP time 30 maxrun 27
action 100 cli command "enable"
action 110 cli command "show ip access-list LOOP"
action 120 set regexp_substr 0
action 130 regexp "range 20 21 \(([0-9]+) matches\)"
$_cli_result _regexp_result regexp_substr
action 140 cli command "clear ip access-list counters LOOP"
action 150 if $regexp_substr gt 0
action 200 set MATCHES $regexp_substr
action 210 file open LOGS $DISK:script-detect-logs.txt a
action 220 cli command "enable"
action 230 cli command "show clock"
action 240 regexp "[0-9]+:[0-9]+:[0-9]+.[0-9]+
est [A-Za-z]+ [A-Za-z]+ [0-9]+ 201[0-9]"
$_cli_result _regexp_result
action 250 set TIME $_regexp_result
action 260 if $MATCHES gt $THRESHOLD_1
action 270 wait 15
action 280 cli command "show ip access-list LOOP"
action 290 set regexp_substr 0
action 300 regexp "range 20 21 \(([0-9]+) matches\)"
$_cli_result _regexp_result regexp_substr
action 310 if $regexp_substr gt $THRESHOLD_2
action 320 cli command "enable"
action 330 cli command "conf t"
action 340 cli command "interface loop100"
action 350 cli command "shut"
action 360 file puts LOGS "$TIME - LOOP DETECTED - Message sent to MC -
matches $MATCHES > $THRESHOLD_1 and $regexp_substr > $THRESHOLD_2"
action 370 wait 5
action 375 cli command "enable"
action 380 cli command "conf t"
action 390 cli command "interface loop100"
action 400 cli command "no shut"
action 410 else
action 420 file puts LOGS "$TIME - TEMPORARY LOOP : matches $MATCHES >
$THRESHOLD_1 and $regexp_substr < or = $THRESHOLD_2"
action 430 cli command "clear ip access-list counters LOOP-DETAIL"
action 440 end
action 450 else
action 460 cli command "en"
action 470 cli command "clear ip access-list counters LOOP-DETAIL"
action 480 file puts LOGS "$TIME - number of matches =
$MATCHES < $THRESHOLD_1"
action 490 end
action 500 else
action 510 cli command "clear ip access-list counters LOOP-DETAIL"
action 520 end
LOOP-MC
Esta seção descreve como criar loopbacks no MC. Aqui estão algumas notas importantes que devem ser lembradas:
event manage environment DISK bootflash
event manager applet LOOP-MC authorization bypass
event syslog pattern "10.100.100.[0-9]/32 reachability Up->Dow" ratelimit 60
action 100 file open LOGS $DISK:script-logs.txt a
action 110 regexp "10.100.100.[0-9]" "$_syslog_msg" _regexp_result
action 120 set BR $_regexp_result
action 130 wait 2
action 140 track read 20
action 150 if $_track_state eq "up"
action 160 cli command "enable"
action 170 cli command "show clock"
action 180 regexp "[0-9]+:[0-9]+:[0-9]+.[0-9]+
est [A-Za-z]+ [A-Za-z]+ [0-9]+ 201[0-9]"
"$_cli_result" _regexp_result
action 190 set TIME "$_regexp_result"
action 200 cli command "show pfr master traffic-class perf det
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 210 cli command "conf t"
action 220 cli command "interface loop200"
action 230 cli command "shut"
action 240 wait 10
action 250 cli command "conf t"
action 260 cli command "interface loop200"
action 270 cli command "no shut"
action 280 cli command "end"
action 290 cli command "clear pfr master *"
action 300 file puts LOGS "$TIME - LOOP DETECTED by $BR -
PfR CLEARED - see $DISK:script-output-$_event_pub_sec.txt"
action 310 syslog priority emergencies msg "LOOP DETECTED by $BR -
PfR CLEARED - see $DISK:script-output-$_event_pub_sec.txt !"
action 320 else
action 330 file puts LOGS "$TIME - REACHABILITY LOST with
$BR - REACHABILITY TO ALL BRs NOT OK - NO ACTION"
action 340 end
COLLECT-BR
Esta seção descreve como coletar o BR. O applet é iniciado quando um BR perde a acessibilidade ao Loopback200 (10.100.100.200) no MC. Os comandos usados para coletar estão listados nas ações 120, 130 e 140.
event manager environment DISK bootflash
event manager applet COLLECT-BR authorization bypass
event syslog pattern "10.100.100.200/32 reachability Up->Dow" ratelimit 45
action 100 file open LOGS $DISK:script-collect-logs.txt a
action 110 cli command "enable"
action 120 cli command "sh ip access-list LOOP-DETAIL |
tee /append $DISK:script-output-$_event_pub_sec.txt"
action 130 cli command "show route-map dynamic detail
| tee /append $DISK:script-output-$_event_pub_sec.txt"
action 140 cli command "show ip route | tee /append
$DISK:script-output-$_event_pub_sec.txt"
action 150 cli command "show clock"
action 160 regexp "[0-9]+:[0-9]+:[0-9]+.[0-9]+ CET [A-Za-z]+ [A-Za-z]+
[0-9]+ 201[0-9]" "$_cli_result" _regexp_result
action 170 set TIME "$_regexp_result"
action 180 file puts LOGS "$TIME - OUTPUTs COLLECTED -
see $DISK:script-output-$_event_pub_sec.txt"
SYSLOG-MC
Aqui está o syslog no MC quando um loop é detectado:
MC#
*Mar 8 08:52:12.529: %TRACKING-5-STATE: 1 ip route 10.100.100.1/32
reachability Up->Down
MC#
*Mar 8 08:52:16.683: %LINEPROTO-5-UPDOWN:
Line protocol on Interface Loopback200, changed state to down
*Mar 8 08:52:16.683: %LINK-5-CHANGED: Interface Loopback200,
changed state to administratively down
MC#
*Mar 8 08:52:19.531: %TRACKING-5-STATE: 1
ip route 10.100.100.1/32 reachability Down->Up
MC#
*Mar 8 08:52:24.727: %SYS-5-CONFIG_I: Configured from console by
on vty0 (EEM:LOOP-MC)
*Mar 8 08:52:24.744: %PFR_MC-1-ALERT: MC is inactive due to PfR
minimum requirements not met;
Less than two external interfaces are operational
MC#
*Mar 8 08:52:24.757: %HA_EM-0-LOG: LOOP-MC:
LOOP DETECTED by 10.100.100.1 - PfR CLEARED
- see unix:script-output-1362732732.txt !
MC#
*Mar 8 08:52:26.723: %LINEPROTO-5-UPDOWN:
Line protocol on Interface Loopback200, changed state to up
MC#
*Mar 8 08:52:26.723: %LINK-3-UPDOWN: Interface Loopback200,
changed state to up
MC#
*Mar 8 08:52:29.840: %PFR_MC-5-MC_STATUS_CHANGE: MC is UP
*Mar 8 08:52:30.549: %TRACKING-5-STATE: 2
ip route 10.100.100.2/32 reachability Up->Down
MC#
*Mar 8 08:52:37.549: %TRACKING-5-STATE: 2
ip route 10.100.100.2/32 reachability Down->Up
MC#