Cisco IOS パイプ(|) 記法の使い方

完全な私のメモです。
INE の有名な動画コースである CCIE Routing & Switching v5.1 Advanced Technologies を視聴していてしきりに
パイプインクルード…ってよく聞こえてきたので、結構活用されているんだなって思って実験結果を書いた。

INE の動画

  1. CCIE Routing & Switching Training – INE
  2. CCIE Routing & Switching Advanced Technologies Course v5.1 – INE

Output Modifier

  1. include 今回紹介するのはこれ
  2. exclude
  3. section 今回紹介するのはこれ
  4. begin

running-config

これを加工していく。

R2#sh run
Building configuration...

Current configuration : 1226 bytes
!
! Last configuration change at 03:36:22 UTC Sat Jan 20 2018
version 15.1
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
dot11 syslog
ip source-route
!
!
!
!
!
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
crypto pki token default removal timeout 0
!
!
!
!
license udi pid CISCO1841 sn FHK130826MD
!
redundancy
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 172.16.123.254 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
!
interface Serial0/0/0
 no ip address
 shutdown
 no fair-queue
 clock rate 2000000
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
!
!
!
!
!
!
control-plane
!
!
banner motd ^C
==============================================================
This is my router. Exit immediately.
===============================================================
^C
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
 exec-timeout 0 0
 login
 transport input all
line vty 5 15
 exec-timeout 0 0
 login
 transport input all
!
scheduler allocate 20000 1000
end

include

指定の文字列を含む行のみを出力する。

普通の使い方

R2#sh run | inc password
no service password-encryption
 password ciscotest
 password ciscotest
 password ciscotest
 password ciscotest

正規表現も使える

R2#sh run | inc (pass|enab)
service password-encryption
enable secret 5 $1$cZtx$Z5Jhba7QXU/olmSSl37Ba0
enable password 7 030752180500204843
 password 7 121A0C0411041C0B3D2E36
 password 7 03075218050035495D1D
 password 7 13061E010803102F3830
 password 7 060506324F411D1C1603

section

line コンフィグレーションモードのセクションを見る。

R2#sh run | sec line con 0
line con 0
 exec-timeout 0 0
 logging synchronous

インターフェース名を省略すると、引っかからない。

R2#sh run | sec int f0/0

インターフェース名を省略せずに指定すると引っかかる。

R2#sh run | sec interface FastEthernet0/0
interface FastEthernet0/0
 ip address 172.16.123.254 255.255.255.0
 duplex auto
 speed auto

show running-config interface

おまけ。
show running-config 単体でこんな使い方もできる。

R2#sh run int f0/0
Building configuration...

Current configuration : 99 bytes
!
interface FastEthernet0/0
 ip address 172.16.123.254 255.255.255.0
 duplex auto
 speed auto
end

Cisco Router: show version, show running-config

show version

R2#show version
Cisco IOS Software, 1841 Software (C1841-ADVENTERPRISEK9-M), Version 15.1(4)M10, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2015 by Cisco Systems, Inc.
Compiled Tue 24-Mar-15 08:30 by prod_rel_team

ROM: System Bootstrap, Version 12.4(13r)T5, RELEASE SOFTWARE (fc1)

R2 uptime is 6 minutes
System returned to ROM by power-on
System image file is "flash:c1841-adventerprisek9-mz.151-4.M10.bin"
Last reload type: Normal Reload


This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco 1841 (revision 7.0) with 352256K/40960K bytes of memory.
Processor board ID FHK123456MD
2 FastEthernet interfaces
1 Serial(sync/async) interface
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity disabled.
191K bytes of NVRAM.
62720K bytes of ATA CompactFlash (Read/Write)


License Info:

License UDI:

-------------------------------------------------
Device#   PID                   SN
-------------------------------------------------
*0        CISCO1841             FHK123456MD



Configuration register is 0x2102

352256K/40960K

(352256+40960)/1024 = 384 MiB

62720K bytes of ATA CompactFlash (Read/Write)

CFメモリのサイズは 62720/1024 ≒ 61 MB

Configuration register is 0x2102

↑コンフィグレーションレジスタの値

GNS3 では

R1#sh ver
Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T14, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Tue 17-Aug-10 12:08 by prod_rel_team

ROM: ROMMON Emulation Microcode
ROM: 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T14, RELEASE SOFTWARE (fc2)

R1 uptime is 3 minutes
System returned to ROM by unknown reload cause - suspect boot_data[BOOT_COUNT] 0x0, BOOT_COUNT 0, BOOTDATA 19
System image file is "tftp://255.255.255.255/unknown"


This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco 3725 (R7000) processor (revision 0.1) with 249856K/12288K bytes of memory.
Processor board ID FTX123456MY
R7000 CPU at 240MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache
3 FastEthernet interfaces
4 Serial interfaces
2 Serial(sync/async) interfaces
DRAM configuration is 64 bits wide with parity enabled.
55K bytes of NVRAM.

Configuration register is 0x2102

show running-config

R2#sh run
Building configuration...

Current configuration : 980 bytes
!
version 15.1
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
dot11 syslog
ip source-route
!
!
!
!
!
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
crypto pki token default removal timeout 0
!
!
!
!
license udi pid CISCO1841 sn FHK130826MD
!
redundancy
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface Serial0/0/0
 no ip address
 shutdown
 no fair-queue
 clock rate 2000000
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
!
!
!
!
!
!
control-plane
!
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
 exec-timeout 0 0
 login
 transport input all
line vty 5 15
 exec-timeout 0 0
 login
 transport input all
!
scheduler allocate 20000 1000
end

インターフェースに関する設定

interface FastEthernet0/0
 ip address 10.1.2.3 255.255.255.0
 speed 100
 full-duplex
!
interface FastEthernet0/1
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface Serial0/0/0
 no ip address
 shutdown
 no fair-queue
 clock rate 2000000
!

http サーバの設定

no ip http server
no ip http secure-server