Ciscoman's notes (Записки цыщика c дипломом)

I'm Cisco Champion Community member for 2017!

I'm Cisco Champion Community member for 2017!
"Cisco Champions are passionate about Cisco and happy to share our knowledge, experience, and feedback."

суббота, 16 апреля 2011 г.

ns-2 network simulator installation on Ubuntu 10.10

Today I was required to install ns-2 from scratch in Ubuntu 10.10.
For this purpose it is needed to download archive from official site, extract it and run ./install in it's directory.
Before that build-essentials package is required to be installed via
apt-get install build-essentials.
After build-essential is installed, you can run ./install. This script will give you the error about undefined reference to `__stack_chk_fail_local' in otcl.c. How can you fix it? Simplest way:
disable stack protection: set the CFLAGS to -fno-stack-protector
For this purpose you can modify "install" on line 497 and set

        ./configure CFLAGS=-fno-stack-protector || die "otcl-$OTCLVER configuration failed! Exiting ...";
instead of
        ./configure || die "otcl-$OTCLVER configuration failed! Exiting ...";
 








пятница, 1 апреля 2011 г.

Do you know what...

- Default ARP entry timeout is 4 hours in IOS!
- DHCP Offer can be sent to all ones broadcast address instead of unicast address in certain situations.
- You can policy route route locally generated broadcast and multicast traffic with "ip local policy". For example this can lead to problems with dhcp server responses  to broadcast address.
- You can't use "match interface" in "ip local policy route-map"
- 255 is inaccessible administrative distance in IOS, you can use it for route filtering
- RIP doesn't generates corresponding Null0 routes for summary addresses opposit to EIGRP and OSPF. This can lead to different interesting situations like routing loops.
- You can't make as-path repend for IBGP routes
- "ip split-horizon" is disabled by default on frame-relay physical interfaces

вторник, 29 марта 2011 г.

ECMP voodo magic


Hi! Today I would like to talk about ECMP in Cisco IOS. As you probably know there are two different methods – per-packet and per-destination load balancing. http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094820.shtml
Default method for IOS is to use per-destination load balancing with CEF. It is possible also to configure per-packet load balancing with CEF, or you can disable CEF and fast-switching to do per-packet.
Let’s look at the following simple topology:

Figure 1. ECMP topology


There is no really nothing unclear with except of two facts. On R1 ECMP is working.  R5 prefer R3 as the default route.   Routing protocol used here has no difference to achieve this configuration.  You can use static routing for simplicity.
Let’s look at the Router2 cef table for prefix 196.254.1.1:

Router2#sh ip cef 196.254.1.1/32 detail
196.254.1.1/32, epoch 0
  NetFlow: Origin AS 0, Peer AS 0, Mask Bits 32
  nexthop 9.8.7.217 GigabitEthernet0/1.996

Then let’s look at the traceroute (1):

Router2#traceroute 196.254.1.1 numeric source l0

Type escape sequence to abort.
Tracing the route to 196.254.1.1

  1 9.8.7.217 0 msec 4 msec 0 msec
  2 172.29.94.83 4 msec 0 msec 4 msec
  3 196.254.1.1 4 msec 0 msec 0 msec

As we expected it, it is per-destination and all three packets gone through 172.29.94.83 gateway, although on Router2 equal cost multipath load sharing is working.  Let’s look at the Router1 CEF table for prefix 196.254.1.1/32 and confirm this:

Router1#sh ip cef 196.254.1.1/32 detail
196.254.1.1/32, epoch 0, per-destination sharing
  NetFlow: Origin AS 0, Peer AS 0, Mask Bits 32
  nexthop 172.29.94.83 GigabitEthernet0/1.324
  nexthop 172.29.94.84 GigabitEthernet0/1.324

Let’s look at the traceroute results now (2):

Router1#traceroute 196.254.1.1 numeric source l0
Type escape sequence to abort.
Tracing the route to 196.254.1.1

  1 172.29.94.84 0 msec
    172.29.94.83 4 msec
    172.29.94.84 4 msec
  2 196.254.1.1 0 msec 0 msec 4 msec
Router1#

Do you see this strange behavior? Nothing strange really except it is per-packet, not per-destination as we was expecting.
Let’s recheck it again with extended ping command on Router2 (3):

Router2#ping
Protocol [ip]:
Target IP address: 196.254.1.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: loopback0
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]: yes
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]: Record
Number of hops [ 9 ]:
Loose, Strict, Record, Timestamp, Verbose[RV]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 196.254.1.1, timeout is 2 seconds:
Packet sent with a source address of 172.22.255.100
Reply data will be validated
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)
   (0.0.0.0)

Reply to request 0 (4 ms).  Received packet has options
 Total option bytes= 40, padded length=40
 Record route:
   (9.8.7.218)
   (172.29.94.81)
   (172.27.175.1)
   (196.254.1.1)
   (196.254.1.1)
   (172.29.94.83)
   (9.8.7.217)
   (172.22.255.100) <*>
   (0.0.0.0)
 End of list

Reply to request 1 (4 ms).  Received packet has options
 Total option bytes= 40, padded length=40
 Record route:
   (9.8.7.218)
   (172.29.94.81)
   (172.27.175.2)
   (196.254.1.1)
   (196.254.1.1)
   (172.29.94.83)
   (9.8.7.217)
   (172.22.255.100) <*>
   (0.0.0.0)
 End of list

Reply to request 2 (4 ms).  Received packet has options
 Total option bytes= 40, padded length=40
 Record route:
   (9.8.7.218)
   (172.29.94.81)
   (172.27.175.1)
   (196.254.1.1)
   (196.254.1.1)
   (172.29.94.83)
   (9.8.7.217)
   (172.22.255.100) <*>
   (0.0.0.0)
 End of list

Reply to request 3 (4 ms).  Received packet has options
 Total option bytes= 40, padded length=40
 Record route:
   (9.8.7.218)
   (172.29.94.81)
   (172.27.175.2)
   (196.254.1.1)
   (196.254.1.1)
   (172.29.94.83)
   (9.8.7.217)
   (172.22.255.100) <*>
   (0.0.0.0)
 End of list

Reply to request 4 (4 ms).  Received packet has options
 Total option bytes= 40, padded length=40
 Record route:
   (9.8.7.218)
   (172.29.94.81)
   (172.27.175.1)
   (196.254.1.1)
   (196.254.1.1)
   (172.29.94.83)
   (9.8.7.217)
   (172.22.255.100) <*>
   (0.0.0.0)
 End of list

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms

Now it is again very confusing! It is per-packet load sharing again. Packets go through 172.27.175.1 and 172.27.175.2 in round-robin fashion! What’s wrong with it?
As I already mentioned, nothing strange there. Answer is simple – packet destined to device itself is processed by control plane of the router and control plane packet is process switched on CPU on IOS. If you know this fact you can understand this behavior easily. In (1) packets processed through router are simply managed by data plane, TTL exceeded is sent.  In (2) and (3) packets processed by R1 control plane. That’s all. There is no cisco voodoo magic.

суббота, 26 марта 2011 г.

How to strike self with a TCL or accidently hang up a router.


We all know that IOS supports TCL scripting. Many of us uses it for different purposes. Some of us uses TCL in IVR/Fax applications, but another frequently usage of TCL is the simple scripts to test reachability:

(tcl)#foreach ip {
+>192.168.1.1
+>150.1.3.3
+>155.1.58.5
+>} {
+>ping $ip rep 3 timeout 1
+>}
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 192.168.1.1, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.3.3, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 155.1.58.5, timeout is 1 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 8/13/20 ms

I often use another script "for start test next command" when working with INE workbook volume 1 to test reachability for each loopback address in the network:

(tcl)#for {set i 1} {$i < 11} {incr i} {
ping 150.1.$i.$i rep 3 time 1 }
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.1.1, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.2.2, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.3.3, timeout is 1 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 8/108/292 ms

and so on for ten addresses, output omitted.

Note the difference to the following script:

for {set $i 1} {$i < 11} {incr $i} {
+>ping 150.1.$i.$i rep 3 time 1 }

Do you see the difference? There is a dollar sign added to the variable $i in “set” and “incr” statements.
The result will be lamentable:

Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.1.1, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.1.1, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort.
Sending 3, 100-byte ICMP Echos to 150.1.1.1, timeout is 1 seconds:
...
Success rate is 0 percent (0/3)
Type escape sequence to abort. 

And so on infinitively. You can not even interrupt it with help of ctrl+shift+6 combination. It will stops only one ping command at once. You will be required to reboot your device to stop this. In the real CCIE lab or production network it can be dangerous and very time wasting.

This infinite loop happens because there is two variables really - “i” and “$i” and operations should reference them as “$i” and “$$i”, but $i variable is not defined yet:

(tcl)#for {set $i 1} {$$i < 11} {incr $i} {
+>ping 150.1.$$i.$$i rep 3 time 1 }   
can't read "i": no such variable

This is very easy and basic problem for anybody who was learning non-interpreted programming languages, but with interpreted script languages such as TCL it can be tricky if you is a network engineer with no programming experience although I hope here is no such people already ;)

вторник, 15 февраля 2011 г.

Cisco IOS Petition

Hi, Fiends! Hope you already know that etherealmind.com in be half of Cisco Networking Community is collecting signatures to make internal Cisco emulators like IOU and L2IOU avaible for education purpose. If not so - don't loose opportunity to sign up for this petition here: http://etherealmind.com/cisco-ios-petition-reloaded/

пятница, 11 февраля 2011 г.

How to conditionally replace two trings with sed

Yesterday I spotted trouble while editing my cisco text configs with large bash script.
 Let's assume we have part of configuration like this:
!
interface FastEthernet0/11
description BB1 E0/0
switchport access vlan 100
switchport mode dynamic desirable
!
interface FastEthernet0/12
switchport mode dynamic desirable
!
If you need to replace "switchport mode dynamic desirable" with "switchport mode trunk", you need first delete string  "switchport mode dynamic desirable" if preceding string is "switchport access vlan 100". In other case your configuration will not work appropriately. You can use vim text editor's command:

:%s/\( switchport access vlan 100\)\n switchport mode dynamic desirable/\1/
But I was unable to do something like this via sed or perl.
It was necessary to ask the opennet.ru community. Thanks to user with nickname temny. He provided this solution:


sed '/switchport access vlan/{N;s!\nswitchport mode dynamic desirable!!;}' file

среда, 9 февраля 2011 г.

eachping.tcl

#-----------------------------------------------------------------------------------------------
#    Simple TCL script for Cisco IOS to ping each device in a column of some command output
#    Author: Eugene K.
#
#    invoke with tclsh eachping.tcl "IOS exec command" "column index"
#    please remeber to quote command argument
#-----------------------------------------------------------------------------------------------

set command [lindex $argv 0]
set index [lindex $argv 1]

if { [ catch {
  foreach line_a [split [exec $command] "\n"] {
      if {[ regexp -inline {[0-9/.]+} [lindex $line_a $index] ] != "" } { ping [lindex $line_a $index] }
  } } e]}  {
  puts "Not enougth arguments or command error. $e"
}

Постоянные читатели

Поиск по этому блогу