Friday, August 31, 2012

Perl Extracting matches

So /\d+/ and /(\d+) will still match as many digits as possible. but in the latter case they will be remembered in a special variable to be back referenced later.

Programming Perl


Extracting matches

The grouping metacharacters () also allow the extraction of the parts of a string that matched. For each grouping, the part that matched inside goes into the special variables $1 , $2 , etc. They can be used just as ordinary variables:

    # extract hours, minutes, seconds
    $time =~ /(\d\d):(\d\d):(\d\d)/; # match hh:mm:ss format
    $hours = $1;
    $minutes = $2;
    $seconds = $3;

http://perldoc.perl.org/perlrequick.html

Monday, August 27, 2012

AnyConnect VPN Client on IOS Router with IOS Zone Based Policy Firewall Configuration Example



In Cisco IOS® Software Release 12.4(20)T and later, a virtual interface SSLVPN-VIF0 was introduced for AnyConnect VPN client connections. But, this SSLVPN-VIF0 interface is an internal interface, which does not support user configurations. This created a problem with AnyConnect VPN and Zone Based Policy Firewall since with the firewall, traffic can only flow between two interfaces when both interfaces belong to security zones. Since the user cannot configure the SSLVPN-VIF0 interface to make it a zone member, VPN client traffic terminated on the Cisco IOS WebVPN gateway after decryption cannot be forwarded to any other interface belonging to a security zone. The symptom of this problem can be seen with this log message reported by the firewall:
*Mar  4 16:43:18.251: %FW-6-DROP_PKT: Dropping icmp session 192.168.1.12:0 192.168.10.1:0 due to One of the interfaces not being cfged for zoning with ip ident 0
This issue was later addressed in newer software releases of Cisco IOS. With the new code, the user can assign a security zone to a virtual-template interface, which is referenced under the WebVPN context, in order to associate a security zone with the WebVPN context .

 AnyConnect VPN Client on IOS Router with IOS Zone Based Policy Firewall Configuration Example

code:

interface Virtual-Template1
 ip unnumbered Loopback0
 zone-member security inside
 !
!
 
Note: reload the router after the change.  
Cisco SSL-VPN LAN Access with Zone Based Policy Firewall 

Monday, August 20, 2012

Automatically backup your router config

There are many ways to automatically backup a router config

1. SNMP poll from a server
How To Copy Configurations To and From Cisco Devices Using SNMP

2. Use TCL/Expect script from a server
Script to backup Cisco Device Config

3. EEM/Kron policy list on a router
Daily backup

4. Using archive IOS command
How to use archive command to save configuration


I think #4 is the easiest one,  all you need is a FTP server.

877wr1(config)#archive
877wr1(config-archive)#time-period
877wr1(config-archive)#write-memory
path ftp://192.168.1.110/backup/$h

!!$h is the variable of hostname

877wr1(config-archive)#?
Archive configuration commands:
  default       Set a command to its defaults
  exit          Exit from archive configuration mode
  log           Logging commands
  maximum       maximum number of backup copies !! the maximum is 14
  no            Negate a command or set its defaults
  path          path for backups
  rollback      Rollback parameters
  time-period   Period of time in minutes to automatically archive the running-config
  write-memory  Enable automatic backup generation during write memory

877wr1#sh archive
The maximum archive configurations allowed is 14.
The next archive file will be named ftp://192.168.1.110/backup/877wr1-1
 Archive #  Name
   1        ftp://192.168.1.110/backup/877wr1-0 <- Most Recent

Friday, August 17, 2012

ESMTP The AUTH Command

The AUTH command is an ESMTP command (SMTP service extension) that is used to authenticate the client to the server. The AUTH command sends the clients username and password to the e-mail server. AUTH can be combined with some other keywords as PLAIN, LOGIN, CRAM-MD5 and DIGEST-MD5 (e.g. AUTH LOGIN) to choose an authentication mechanism. The authentication mechanism chooses how to login and which level of security that should be used. 

Below are the AUTH LOGIN  commands/mechanisms described.

S: 220 smtp.server.com Simple Mail Transfer Service Ready
C: EHLO client.example.com
S: 250-smtp.server.com Hello client.example.com
S: 250-SIZE 1000000
S: 250 AUTH LOGIN PLAIN CRAM-MD5
C: AUTH LOGIN
S: 334 VXNlcm5hbWU6
C: adlxdkej  <<<<<<<<<<<<<<<base64 converted username
S: 334 UGFzc3dvcmQ6
C: lkujsefxlj
<<<<<<<<<<<<<<<base64 converted password
S: 235 2.7.0 Authentication successful


The AUTH Command 

Difference Between LOOKUP Function and VLOOKUP in Excel

The vector syntax for LOOKUP looks for a matching value in a range of cells (vertical or horizontal) and returns the value in the matching vector position of the second supplied range. It is similar to VLOOKUP and HLOOKUP; however, it is limited to a single row or column to hold results.

VLOOKUP looks for a matching value in the first column of a range of cells and returns the value from the same row in the column of the range you specify. The range can have multiple columns. LOOKUP would have only one column to choose from.

To discrbe the difference, I would say LOOKUP has a single column or row range to hold the lookup values, and a single column or row range to hold the return values. The return range does not need to be adjacent to the lookup range, but can be. VLOOKUP can have multiple columns, the first being the lookup column. The other columns hold the result values and are choosen by the column parameter. The VLOOKUP fucntion uses a single multi-cell range.

What's the difference between LOOKUP function and VLOOKUP in Excel?

Thursday, August 16, 2012