勉強日記

チラ裏

CCNA試験対策 下巻ch11: Quality of Service (QoS)

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Introduction to QoS

  • 例えばWAN edgeのrouterは、WAN側は遅く、LAN側は速い
  • ので、LAN側に数百数千のパケットが渋滞しうる
  • どうする? -- QoS

QoS: Managing Bandwidth, Delay, Jitter, and Loss

  • ネットワークのトラフィックの特性
    • Bandwidth
      • bps
      • 速度と捉えることもできるし、キャパシティと捉えることもできる
        • 10%をvoice、50%をmission-critial、残りを普通のトラフィックに充てる、など
    • Delay
      • one-way delay: 送信して届くまで
      • round-trip delay: パケットを1つ送信して1つ返ってくるまで
    • Jitter
      • delayのばらつき
    • Loss
      • sentを分母とする百分率
      • 要因
        • faulty cabling
        • WANサービス側の問題
        • LAN側のキューあふれ
        • など

Types of Traffic

Data Applications

  • ユーザが求めているのは良いQoE (Quality of Experience)
  • アプリケーションによって求められるQoS特性は異なるという話
    • 例: バッチ
      • delayやjitterは大した問題にならない
      • bandwidthが大きいことやlossが少ないことが重要

Voice and Video Applications

voice video
bandwidth ? 384kbpbs - 20+Mbps
delay < 150ms 200-400ms
jitter < 30ms < 30-50ms
loss < 1% 0.1% - 1%

QoS on Switches and Routers

  • 本章では便宜上packet/frameの区別をしないこととする
    • 重要でないので

Classification and Marking

Classification Basics

  • 他のQoSツールの前段
  • パケットを分類する

Matching (Classification) Basics

  • パケットが通過する全デバイスで複雑なマッチングをするのは得策でない
    • パフォーマンスに悪影響がある
  • 早期に複雑なマッチングを済ませてマーキングし、以降はマーキングに基づいて簡単なマッチングで済ませるのが得策
  • DSCP: Differentiated Services Code Point
    • マーキング用のフィールド

Classification on Routers with ACLs and NBAR

  • QoS実現のためにはパケットの分類が必要
  • ACLでパケットを分類できる
  • ACLでうまく分類できない場合はNBARという選択肢もある
  • NBAR: Network Based Application Recognition
    • 一般的にNBAR2 -- next-generation NBAR のこと
    • アプリケーション層の情報まで利用してパケットを分類する

Marking IP DSCP and Ethernet CoS

  • CoS: L2のQoS用フィールド
  • DSCP: L3のQoS用フィールド
CoS DSCP
voice 5 EF
video 4 AF41
business-critical 2 AF21

Marking the IP Header

  • 送信元ホストから宛先ホストまでずっと残る
    • ルータホップ時、L2フレームは剥がすがL3ヘッダは破棄しない
  • ToSフィールド(8ビット)
    • 昔: IPP: IP Precedence フィールドとして3ビットだけ使われていた
    • 今: DSCPフィールドに6ビット使っている

Marking the Ethernet 802.1Q Header

  • CoS (3ビット)
    • 802.1Qタグに含まれる
    • ので、利用できるのはトランクリンクに限られる
      • VLAN越えられない

Other Marking Fields

Defining Trust Boundaries

  • ホストは好き勝手にDSCPやCoSを設定してパケットを送信できる
  • voice packetじゃないのにEF (Expedited Forwarding)を設定したりできる
  • ので、DSCPやCoSを無条件に信じるわけにはいかない
  • Trust Boundaries
    • ここからのパケットのDSCPやCoSは信じますよ、という境界
    • 典型的にはfirst ingress switchやIP phone

DiffServ Suggested Marking Values

  • DSCP値の標準化みたいな話
  • RFC2475

Expedited Forwarding (EF)

  • 10進数の46番
  • 音声データ用
    • cf. voice signaling packetはCS3

Assured Forwarding (AF)

Best Drop Worst Drop
Best Queue AF41 (34) AF42 (36) AF43 (38)
AF31 (26) AF32 (28) AF33 (30)
AF21 (18) AF22 (20) AF23 (22)
Worst Queue AF11 (10) AF12 (12) AF13 (14)
  • 4種のキュー
  • 各キューの中でのdrop優先度
  • 8の倍数がないのは後述のCSに割り当てられているため

Class Selector (CS)

  • IPP互換
    • 3ビットのIPP (000 ~ 111)が6ビットのDSCP(000000 ~ 111000)になったので、8の倍数
IPP CS DSCP
0 CS0 0
1 CS1 8
2 CS2 16
3 CS3 24
4 CS4 32
5 CS5 40
6 CS6 48
7 CS7 56

Guidelines for DSCP Marking Values

  • 結局どういうときにどれ使えばいいの
    • DSCP EF: Voice payload
    • AF4x: Interactive video
      • ビデオ会議とか
    • AF3x: Streaming video
    • AF2x: High priority (low latency) data
    • CS0: Standard data

Queuing

  • 出力インタフェースがbusyなときにパケットを溜めておくやつ
    1. 受信したパケットをclassifierで分類し
    2. 分類ごとにqueueに積み
    3. schedulerで優先度づけして送信する

Round-Robin Scheduling (Prioritization)

Low Latency Queuing

  • 対話的な音声(電話など)や映像(ビデオ会議など)では、重み付けラウンドロビンでは十分なlow latency/jitter/loss特性を得られない
  • スケジューラにLLQ: Low Latency Queuingを追加することで解決する
    • 最優先なキュー
  • 新たに生じる問題: queue starvation
    • interfaceの処理能力以上のトラフィックがLLQに入ってきたら、他のキューが処理されなくなる
  • 解決法: policing
    • LLQに最大帯域幅を設定し、あふれたパケットを破棄する
  • 新たに生じる問題: 音声パケットのロスが生じる
  • 解決法: CAC: Call Admission Control
    • 詳細は割愛

Shaping and Policing

  • このまま送受信したらトラフィックがあふれてしまう、という時
    • shaping: queueに積んで送信を遅延する
    • policing: 破棄するか、優先度の低い値で再マーキングする

Policing

Where to Use Policing

  • SPのネットワーク機器(受信側)でトラフィック制限
    • 顧客から過剰のトラフィックを送りつけられたら破棄する or 優先度の低い値で再マーキングする

Shaping

  • 送信側で設定
  • トラフィックが設定値をあふれないようにqueueに積んで送信を遅延する

Setting a Good Shaping Time Interval for Voice and Video

  • 送信を遅延するので、当然delayとjitterが増大する
  • 例: 1000Mbpsのinterfaceのegress trafficを200MbpsにShapingする場合
  • shaperのtime intervalが1000msだと、
    200ms送信・800ms待機・200ms送信・800ms待機…という挙動になる
  • 800msのdelayが生じるということ
    • voice packetには耐えない
  • 解決法: shaperのtime intervalを短く設定する
    • 対話的音声や映像には10ms程度
      • 2ms送信・8ms待機…となる

Congestion Avoidance

TCP Windowing Basics

  • windowing
    • window
      • TCPコネクションにおいて、senderが一度に送信してよいバイト数
    • windowに達したら、receiverからackを受け取るまで送信を待機する
    • 待機時間は無駄なので、これを無くすために、receiverはackするたびにwindowを倍々にしていく
    • 輻輳によるパケットロスが検出されたらwindowを狭める
  • tail drop
    • ネットワーク機器のqueueが一杯になり、新たなパケットが破棄される状態

Congestion Avoidance Tools

  • tail dropを未然に防ぐために、TCPセグメントを破棄する
    • TCPコネクションはパケットロスを検出してwindowを狭める
    • tail dropよりも長い目で見てマシ

CCNA試験対策 下巻ch10: Network Address Translation

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Perspectives on IPv4 Address Scalability

CIDR

  • RFC4632
  • 知ってるので略

Private Addressing

  • RFC1918
  • 知ってるので略

Network Address Translation Concepts

  • RFC3022
  • private networkのprivate IPv4 addressはインターネットでは通用しない
  • ので、インターネットにパケットを送出する際に、source IPv4 addressをISPから買ったpublic registered IPv4 addressに変換する必要がある
  • 逆に、インターネットから入ってくるパケットのdestination IPv4 addressをprivate networkのprivate IPv4 addressに変換する必要もある
  • private network -> public networkにおいて…
    • Inside Local: 変換前のsource address
    • Inside Global: 変換後のsource address
    • Outside Local: 変換前のdestination address
    • Outside Global: 変換後のdestination address

Static NAT

  • NAT Tableを静的に設定するやつ

Dynamic NAT

  • NAT Tableが動的に設定されるやつ
    • localとglobalのIPアドレスの1対1関係自体は変わらない
    • 利用可能なinside global addressのPoolを設定しておく

Overloading NAT with Port Address Translation

NAT Configuration and Troubleshooting

Static NAT Configuration

f:id:wand_ta:20200629001955p:plain

  • 10.1.1.1から170.1.1.1pingする場合
  • NATを設定しない場合、170.1.1.1デフォルトゲートウェイ170.1.1.254で応答パケットが破棄される
    • 10.*.*.* (class A private address)へのroutingがないので

f:id:wand_ta:20200629002003p:plain

  • NATを設定する
  • まず、どのinterfaceがinside、どのinterfaceがoutsideかを設定
    • Static,Dynamic,PAT 共通
NAT(config)#interface g0/0/0
NAT(config-if)#ip nat inside
NAT(config-if)#
NAT(config-if)#interface g0/0/1
NAT(config-if)#ip nat outside
NAT(config-if)#exit
  • NATを静的に設定
NAT(config)#ip nat inside source static 10.1.1.2 200.1.1.2
NAT(config)#ip nat inside source static 10.1.1.1 200.1.1.1
  • NATテーブル確認
    • staticなので設定時点でNATテーブルにエントリが追加されている
NAT#show ip nat translations
Pro  Inside global     Inside local       Outside local      Outside global
---  200.1.1.1         10.1.1.1           ---                ---
---  200.1.1.2         10.1.1.2           ---                ---
  • アドレス変換の統計情報
NAT#show ip nat statistics
Total translations: 2 (2 static, 0 dynamic, 0 extended)
Outside Interfaces: GigabitEthernet0/0/1
Inside Interfaces: GigabitEthernet0/0/0
Hits: 0  Misses: 0
Expired translations: 0
Dynamic mappings:
C:\>ping 170.1.1.1

Pinging 170.1.1.1 with 32 bytes of data:

Request timed out.
Reply from 170.1.1.1: bytes=32 time=12ms TTL=125
Reply from 170.1.1.1: bytes=32 time<1ms TTL=125
Reply from 170.1.1.1: bytes=32 time<1ms TTL=125

Ping statistics for 170.1.1.1:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 12ms, Average = 4ms
  • 統計情報に反映された
NAT#show ip nat statistics
Total translations: 10 (2 static, 8 dynamic, 8 extended)
Outside Interfaces: GigabitEthernet0/0/1
Inside Interfaces: GigabitEthernet0/0/0
Hits: 7  Misses: 8
Expired translations: 0
Dynamic mappings:
  • パケットのIPv4アドレスが書き換わっていることも確認できる
  • pingのsource

f:id:wand_ta:20200629002018p:plain

f:id:wand_ta:20200629002027p:plain

Dynamic NAT Configuration

  • NATを行うrouterでinside/outsideを設定するのは同じ
  • insideはACLでマッチして、outsideは利用可能なpublic registered ip addressesのpoolを定義しておく
NAT(config)#ip nat pool hoge 200.1.1.1 200.1.1.2 netmask 255.255.255.252
NAT(config)#ip nat inside source list 1 pool hoge
NAT(config)#
NAT(config)#access-list 1 permit 10.1.1.2
NAT(config)#access-list 1 permit 10.1.1.1
  • ping from 10.1.1.1
C:\>ping 170.1.1.1

Pinging 170.1.1.1 with 32 bytes of data:

Reply from 170.1.1.1: bytes=32 time=1ms TTL=125
Reply from 170.1.1.1: bytes=32 time<1ms TTL=125
Reply from 170.1.1.1: bytes=32 time<1ms TTL=125
Reply from 170.1.1.1: bytes=32 time<1ms TTL=125

Ping statistics for 170.1.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

Dynamic NAT Verification

  • 10.1.1.1 <-> 200.1.1.1の変換だけがNATテーブルに追加される
NAT#show ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
icmp 200.1.1.1:18      10.1.1.1:18        170.1.1.1:18       170.1.1.1:18
icmp 200.1.1.1:19      10.1.1.1:19        170.1.1.1:19       170.1.1.1:19
icmp 200.1.1.1:20      10.1.1.1:20        170.1.1.1:20       170.1.1.1:20
icmp 200.1.1.1:21      10.1.1.1:21        170.1.1.1:21       170.1.1.1:21
  • 統計情報には Dynamic mappings:に情報が追加される
NAT#show ip nat statistics
Total translations: 0 (0 static, 0 dynamic, 0 extended)
Outside Interfaces: GigabitEthernet0/0/1
Inside Interfaces: GigabitEthernet0/0/0
Hits: 11  Misses: 12
Expired translations: 12
Dynamic mappings:
-- Inside Source
access-list 1 pool hoge refCount 0
 pool hoge: netmask 255.255.255.252
       start 200.1.1.1 end 200.1.1.2
       type generic, total addresses 2 , allocated 0 (0%), misses 0
  • NATテーブルの動的に追加されたエントリは clear ip nat translationコマンドで削除できる
NAT#clear ip nat translation *
NAT#show ip nat translations 
(空)

NAT Overload (PAT) Configuration

  • overloadをつけるだけ
  • poolのエントリが1件しかないケースを考える
NAT(config)#ip nat pool hoge 200.1.1.1 200.1.1.1 netmask 255.255.255.252
NAT(config)#ip nat inside source list 1 pool hoge overload 
  • 10.1.1.1, 10.1.1.2 からpingした直後
NAT#show ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
icmp 200.1.1.1:10      10.1.1.2:10        170.1.1.1:10       170.1.1.1:10
icmp 200.1.1.1:11      10.1.1.2:11        170.1.1.1:11       170.1.1.1:11
icmp 200.1.1.1:12      10.1.1.2:12        170.1.1.1:12       170.1.1.1:12
icmp 200.1.1.1:30      10.1.1.1:30        170.1.1.1:30       170.1.1.1:30
icmp 200.1.1.1:31      10.1.1.1:31        170.1.1.1:31       170.1.1.1:31
icmp 200.1.1.1:32      10.1.1.1:32        170.1.1.1:32       170.1.1.1:32
icmp 200.1.1.1:33      10.1.1.1:33        170.1.1.1:33       170.1.1.1:33
icmp 200.1.1.1:9       10.1.1.2:9         170.1.1.1:9        170.1.1.1:9
  • IPアドレス200.1.1.1に変換されていることがわかる
  • PATではport番号でmultiplexできるので、pool自体不要で、NAT routerのoutside側interfaceのIPアドレスを利用することもできる
ip nat inside source list 1 interface g0/0/1 overload
  • NAT routerのoutside側、つまり200.1.1.251との変換が行われる
NAT#show ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
icmp 200.1.1.251:13    10.1.1.2:13        170.1.1.1:13       170.1.1.1:13
icmp 200.1.1.251:14    10.1.1.2:14        170.1.1.1:14       170.1.1.1:14
icmp 200.1.1.251:15    10.1.1.2:15        170.1.1.1:15       170.1.1.1:15
icmp 200.1.1.251:16    10.1.1.2:16        170.1.1.1:16       170.1.1.1:16
icmp 200.1.1.251:34    10.1.1.1:34        170.1.1.1:34       170.1.1.1:34
icmp 200.1.1.251:35    10.1.1.1:35        170.1.1.1:35       170.1.1.1:35
icmp 200.1.1.251:36    10.1.1.1:36        170.1.1.1:36       170.1.1.1:36
icmp 200.1.1.251:37    10.1.1.1:37        170.1.1.1:37       170.1.1.1:37
  • poolは使わなくなったのでDynamic mappings:の項は無くなった
NAT#show ip nat statistics
Total translations: 8 (0 static, 8 dynamic, 8 extended)
Outside Interfaces: GigabitEthernet0/0/1
Inside Interfaces: GigabitEthernet0/0/0
Hits: 49  Misses: 52
Expired translations: 32
Dynamic mappings:

CCNA試験対策 下巻ch9: Device Management Protocols

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Chapter 9: Device Management Protocols

System Message Logging (Syslog)

Sending Messages in Real Time to Current Users

  • デフォルトで全severity出力

Storing Log Messages for Later Review

Router(config)#logging ?
  A.B.C.D   IP address of the logging host
  buffered  Set buffered logging parameters
  console   Set console logging parameters
  host      Set syslog server IP address and parameters
  on        Enable logging to all enabled destinations
  trap      Set syslog server logging level
  userinfo  Enable logging of user info on privileged mode enabling
  • buffered
    • 本体のRAM
  • console
    • console
  • monitor
    • vty
      • Packet Tracerでは動かない
  • host
    • syslogサーバ
    • プロダクション環境ではこれ
    • severity levelの設定はtrapで行う(後述)

Log Message Format

Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface GigabitEthernet0/0/0, changed state to up
  • こういうやつ
Router(config)#service timestamps log datetime msec

Router(config)#interface g0/0/1
Router(config-if)#no shutdown

*3 01, 00:04:03.044: %LINK-5-CHANGED: Interface GigabitEthernet0/0/1, changed state to up
  • A timestamp
    • *3 01, 00:04:03.044:
  • The facility on the router that generated the message
    • %LINK
  • The severity level
    • 5
  • A mnemonic for the message
    • CHANGED
  • The description of the message
    • Interface GigabitEthernet0/0/1, changed state to up

Log Message Severity Levels

Keyword Numeral 分類
Emergency 0 severe
Alert 1 severe
Critical 2 impactful
Error 3 impactful
Warning 4 impactful
Notification 5 normal
Informational 6 normal
Debug 7 debug
  • logging console 4 のようにするとコンソールのログ出力をWarning以上(0-4)に絞ることができる
    • Packet Tracerでは動かなかった

Configuring and Verifying System Logging

Router#show logging
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited,
          0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.


No Inactive Message Discriminator.


    Console logging: level debugging, 3 messages logged, xml disabled,
          filtering disabled
    Monitor logging: level debugging, 3 messages logged, xml disabled,
          filtering disabled
    Buffer logging:  disabled, xml disabled,
          filtering disabled

    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped
    Trap logging: level informational, 3 message lines logged

The debug Command and Log Messages

  • severity level 7 (debug)は特殊用途
  • debugコマンド出力用
Router(config)#interface loopback 0

Router(config-if)#ip address 172.16.1.1 255.255.255.0
Router(config-if)#^Z

Router#ping 172.16.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/2/5 ms
  • icmpメッセージのdebug logが出る
Router#debug ip icmp 
ICMP packet debugging is on
Router#ping 172.16.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!
ICMP: echo reply sent, src 172.16.1.1, dst 172.16.1.1

ICMP: echo reply rcvd, src 172.16.1.1, dst 172.16.1.1
!
ICMP: echo reply sent, src 172.16.1.1, dst 172.16.1.1

ICMP: echo reply rcvd, src 172.16.1.1, dst 172.16.1.1
!
ICMP: echo reply sent, src 172.16.1.1, dst 172.16.1.1

ICMP: echo reply rcvd, src 172.16.1.1, dst 172.16.1.1
!
ICMP: echo reply sent, src 172.16.1.1, dst 172.16.1.1

ICMP: echo reply rcvd, src 172.16.1.1, dst 172.16.1.1
!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/5 ms

Router#
ICMP: echo reply sent, src 172.16.1.1, dst 172.16.1.1

ICMP: echo reply rcvd, src 172.16.1.1, dst 172.16.1.1

Router#
  • CPUを食うので気をつける
  • 全無効化
Router#no debug all
All possible debugging has been turned off

Network Time Protocol (NTP)

  • 時計を合わせましょうという話
    • メッセージを突合しやすくなる
    • プロトコルによっては時刻がずれすぎると動作しない

Setting the Time and Timezone

Router(config)#clock timezone GST 9
Router(config)#^Z
Router#clock set 19:28:00 28 June 2020
Router#show clock
4:28:3.880 GST Mon Jun 29 2020
Router(config)#clock timezone JST 0
Router(config)#^Z
%SYS-5-CONFIG_I: Configured from console by console

Router#show clock
19:28:25.31 JST Sun Jun 28 2020

Basic NTP Configuration

command as an NTP client as an NTP master
ntp master x o
ntp server o o
  • ntp serverはNTPサーバ/クライアント兼任するので、数珠つなぎできる
    • Stratum 3,4,...
R1(config)#interface g0/0/0
R1(config-if)#ip address 10.0.0.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#ntp master 2
R1(config)#end
R2(config)#interface g0/0/0
R2(config-if)#ip address 10.0.0.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
R2(config-if)#exit
R2(config)#ntp server 10.0.0.1
  • 定期的に時刻同期する
R2#debug ntp packets 
NTP packets debugging is on

R2#6 28 19:41:24.418: NTP: xmit packet to 10.0.0.1
6 28 19:41:40.496: NTP: xmit packet to 10.0.0.1
6 28 19:41:56.560: NTP: xmit packet to 10.0.0.1
6 28 19:42:12.633: NTP: xmit packet to 10.0.0.1
6 28 19:42:28.751: NTP: xmit packet to 10.0.0.1
6 28 19:42:44.856: NTP: xmit packet to 10.0.0.1
6 28 19:43:00.932: NTP: xmit packet to 10.0.0.1
6 28 19:43:17.014: NTP: xmit packet to 10.0.0.1

NTP Reference Clock and Stratum

  • stratumの話
    • NTPの仕様的にNTPサーバには15までしか設定できないので注意
R1#show ntp status
Clock is synchronized, stratum 2, reference is 127.127.1.1
nominal freq is 250.0000 Hz, actual freq is 249.9990 Hz, precision is 2**24
reference time is 0C6E07DE.00000302 (20:30:22.770 UTC 日 6 28 2020)
clock offset is 0.00 msec, root delay is 0.00  msec
root dispersion is 0.00 msec, peer dispersion is 0.48 msec.
loopfilter state is 'CTRL' (Normal Controlled Loop), drift is - 0.000001193 s/s system poll interval is 6, last update was 18 sec ago.
R1#show ntp associations 

address         ref clock       st   when     poll    reach  delay          offset            disp
*~127.127.1.1   .LOCL.          1    11       64      377    0.00           0.00              0.48
 * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured

Redundant NTP Configuration

ntp server time-a-b-nist.cov
ntp server time-a-g-nist.cov
ntp master
  • インターネット上のNTPサーバーの接続が絶たれたらinternal clockにフェイルオーバーして自身がNTPサーバーになる

NTP Using a Loopback Interface for Better Availability

  • 経路を冗長化しているとき、特定の物理interfaceのIPアドレスを設定すべきでない
    • そのrouterに到達可能でも、そのinterfaceがdownになったらNTPの同期がとれなってしまうため
  • こういうときはloopback interfaceを用いる
    • routerが生きていて、かつ明示的にshutdownしない限り常にup/upな論理interface
    • OSPFのRIDに使ったりもした
  • サーバの設定
R1(config)#interface loopback 0
R1(config-if)#ip address 1.2.3.4 255.255.255.255
R1(config-if)#exit
R1(config)#ntp source loopback 0
  • ntp source <interface>はPacket Tracerで動作しなかった
  • routing確認
R1#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.2.3.4/32 is directly connected, Loopback0
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       10.0.0.0/24 is directly connected, GigabitEthernet0/0/0
L       10.0.0.1/32 is directly connected, GigabitEthernet0/0/0

これ:

C       1.2.3.4/32 is directly connected, Loopback0
  • どの物理interfaceから入ってきたかによらず、このrouterにさえ到達できれば疎通できるIPアドレス
  • クライアント側も設定
    • しかるべきrouting設定をしてあること
R2(config)#ntp server 1.2.3.4

Analyzing Topology Using CDP and LLDP

Examining Information Learned by CDP

  • Cisco Discovery Protocol
  • Cisco独自の隣接ノード探索プロトコル
  • やりとりできる情報
    • Device identifier
      • ホスト名など
    • Address list
    • Port identifier
    • Capabilities list
      • routerかswitchか、など
    • Platform
      • モデル、OSレベルなど
R2#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID    Local Intrfce   Holdtme    Capability   Platform    Port ID
R1           Gig 0/0/0        126            R       ISR4300     Gig 0/0/0
R2#show cdp neighbors detail

Device ID: R1
Entry address(es): 
  IP address : 10.0.0.1
Platform: cisco ISR4300, Capabilities: Router
Interface: GigabitEthernet0/0/0, Port ID (outgoing port): GigabitEthernet0/0/0
Holdtime: 152

Version :
Cisco IOS Software [Everest], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4,RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Sun 08-Jul-18 04:33 by mcpre

advertisement version: 2
Duplex: full
  • hostname指定可能
R2#show cdp entry R1

Device ID: R1
Entry address(es): 
  IP address : 10.0.0.1
Platform: cisco ISR4300, Capabilities: Router
Interface: GigabitEthernet0/0/0, Port ID (outgoing port): GigabitEthernet0/0/0
Holdtime: 133

Version :
Cisco IOS Software [Everest], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4,RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Sun 08-Jul-18 04:33 by mcpre

advertisement version: 2
Duplex: full

Configuring and Verifying CDP

  • グローバルで有効/無効化設定できる(run)
R2(config)#cdp ?
  run  Enable CDP
  • interfaceごとに設定上書きできる(enable)
    • 送信/受信個別の設定はできない (cf. lldpはできる)
R2(config-if)#cdp ?
  enable  Enable CDP on interface
  • CDP自体の有効/無効の確認、update/holdtime timerの確認
R2#show cdp
Global CDP information:
    Sending CDP packets every 60 seconds
    Sending a holdtime value of 180 seconds
    Sending CDPv2 advertisements is enabled
  • 個々のinterfaceについて確認
R2#show cdp interface ?
  Ethernet         IEEE 802.3
  FastEthernet     FastEthernet IEEE 802.3
  GigabitEthernet  GigabitEthernet IEEE 802.3z
  Serial           Serial
  <cr>
R2#show cdp interface g0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds
  • トラフィックの統計情報を確認できるらしいがPacket Tracerで動作せず:
R2#show cdp traffic

Examining Information Learned by LLDP

  • Link Layer Discovery Protocol
  • IEEE802.1AB標準
  • デフォルト無効
R2#show lldp neighbors 
% LLDP is not enabled
  • 有効化
R2(config)#lldp run 
R2(config)#^Z
R2#show lldp neighbors 
Capability codes:
    (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device
    (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other
Device ID           Local Intf     Hold-time  Capability      Port ID
R1                  Gig0/0/0       120        R               Gig0/0/0
  • CDPとの比較
R2#show cdp neighbors 
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID    Local Intrfce   Holdtme    Capability   Platform    Port ID
R1           Gig 0/0/0        137            R       ISR4300     Gig 0/0/0
  • LLDPをCDPと比較したときの特徴
    • platform情報がない
    • capability codesが異なる
      • B (bridge) ... L2SW台頭前のportが数個しかないやつ
R2#show lldp neighbors detail 
------------------------------------------------
Chassis id: 0030.A33D.4801
Port id: Gig0/0/0
Port Description: GigabitEthernet0/0/0
System Name: R1
System Description:
Cisco IOS Software [Everest], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4,RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Sun 08-Jul-18 04:33 by mcpre
Time remaining: 90 seconds
System Capabilities: R
Enabled Capabilities: R
Management Addresses - not advertised
Auto Negotiation - supported, enabled
Physical media capabilities:
    1000baseT(FD)
Media Attachment Unit type: 10
Vlan ID: 1

Total entries displayed: 1
  • show lldp entry <hostname>で特定のhostの情報だけ取得できるはずだが、Packet Tracerで動作せず

Configuring and Verifying LLDP

  • グローバルコンフィグで有効/無効化できる(run)
R2(config)#lldp  ?
  run  Enable LLDP
  • ほか、interfaceごとに受信(receive)/送信(transmit)の有効/無効化ができる
R2(config)#int g0/0/0
R2(config-if)#lldp ?
  receive   Enable LLDP reception on interface
  transmit  Enable LLDP transmission on interface
  • グローバル設定確認
R2#show lldp

Global LLDP Information:
    Status: ACTIVE
    LLDP advertisements are sent every 30 seconds
    LLDP hold time advertised is 120 seconds
    LLDP interface reinitialisation delay is 2 seconds
  • show lldp interface <interface>でインタフェースごとの設定確認もできるはずだがPacket Tracerでは動作せず
  • show lldp trafficで統計情報を確認できるはずだが、やはりPacket Tracerでは動作せず

英語

  • by virtue of
    • おかげで

CCNA試験対策 下巻ch8: DHCP Snooping and ARP Inspection (2/2)

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Dnyamic ARP Inspection

DAI Concepts

Review of Normal IP ARP

  • ARP SpoofingとDAIの理解のためにはまず正常なARPフローの理解が必要
  • ARP要求側はもちろん、応答側も相手のIPアドレス-MACアドレス対応を学習するという点が肝

Gratuitous ARP as an Attack Vector

  • GARP: Gratuitous ARP
    • 自身のIPアドレスをSource IP address/Target IP addressにセットしてブロードキャストする
  • GARPの目的
    • 自身のIPアドレスの重複検出
      • 返答が返ってきたら重複があるということ
    • broadcast domain内のARPキャッシュ更新
      • ARP応答側も学習するので
  • 後者を攻撃に利用できる
    • ARPキャッシュを汚染し、MITM攻撃に繋げる

Dynamic ARP Inspection Logic

  • DAIのアイディア: DHCP Snooping Binding Tableを用いてARPメッセージの正当性を確認する
  • DHCPを利用していない場合はARP ACLsを利用する
  • DHCPのCHADDRのチェック同様、IEEE802.3ヘッダのsource MAC address等の照合有効化することもできる

Dynamic ARP Inspection Configuration

Configuring ARP Inspection on a Layer 2 Switch

ip arp inspection vlan 1
!
ip dhcp snooping vlan 1
no ip dhcp snooping information option
ip dhcp snooping
...
!
interface GigabitEthernet0/1
 ip arp inspection trust
 ip dhcp snooping trust
 ip dhcp snooping limit rate 10

これと

ip arp inspection vlan 1

これ

interface GigabitEthernet0/1
 ip arp inspection trust
  • ステータス
Switch#show ip arp inspection

Source Mac Validation      : Disabled
Destination Mac Validation : Disabled
IP Address Validation      : Disabled

 Vlan     Configuration    Operation   ACL Match          Static ACL
 ----     -------------    ---------   ---------          ----------
    1     Enabled          Inactive

 Vlan     ACL Logging      DHCP Logging      Probe Logging
 ----     -----------      ------------      -------------
    1     Deny             Deny              Off

 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
    1              4              0              0              0

 Vlan   DHCP Permits    ACL Permits  Probe Permits   Source MAC Failures
 ----   ------------    -----------  -------------   -------------------
    1              4              0              0                     0

 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
    1                   0                        0                       0
  • DAIでDHCP Snooping binding tableに乗っかる場合、テーブルを確認できる
Switch#show ip dhcp snooping binding 
MacAddress          IpAddress        Lease(sec)  Type           VLAN  Interface
------------------  ---------------  ----------  -------------  ----  -----------------
00:01:64:DB:A5:C5   10.0.1.52        86400       dhcp-snooping  1     FastEthernet0/1
00:E0:F9:57:1A:AA   10.0.1.51        86400       dhcp-snooping  1     FastEthernet0/2
Total number of bindings: 2
  • DAIの統計情報
Switch#show ip arp inspection statistics 

 Vlan      Forwarded        Dropped     DHCP Drops     ACL Drops
 ----      ---------        -------     ----------     ---------
    1              4              0              0             0

 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
    1              4              0                     0

 Vlan   Dest MAC Failures   IP Validation Failures
 ----   -----------------   ----------------------
    1                   0                        0

Limiting DAI Message Rates

Switch(config-if)#ip arp inspection limit rate 8 burst interval 4
  • DHCP Snooping同様↑のように設定できるはずだが、Packet Tracerでは設定できなかった…
  • 設定確認
Switch#show ip arp inspection interface
Interface        Trust State     Rate(pps)    Burst Interval
---------------  -----------     ---------    --------------
Fa0/1            Untrusted              15                 1
Fa0/2            Untrusted              15                 1
...
Gig0/1           Trusted                15                 1
Gig0/2           Untrusted              15                 1
  • Rate
    • packets per seconds
  • Burst Interval
    • 連続してこの秒数Rateを超過したら、当該interfaceはerr-disabledになる

Configuring Optional DAI Message Checks

Switch(config)#ip arp inspection validate ?
  dst-mac  Validate destination MAC address
  ip       Validate IP address
  src-mac  Validate source MAC address
  • デフォルトですべて無効になっている
Switch#show ip arp inspection 

Source Mac Validation      : Disabled
Destination Mac Validation : Disabled
IP Address Validation      : Disabled
...
  • 有効化するとCPUを食うが、より広範な攻撃から防御できるようになる

CCNA試験対策 下巻ch8: DHCP Snooping and ARP Inspection (1/2)

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


DHCP Snooping

DHCP Snooping Concepts

  • L2ポート上で動作するACLFirewallのような機能
    • DHCP自体はL3で動作することに注意
  • DHCP Snoopingではポートを2つに分類する
    • trusted
      • switch,router,DHCPサーバなどが繋がっているポート
    • untrusted
      • PC、APなどが繋がっているポート
  • DHCP Snooping概略
    • untrustedポートに、通常DHCPサーバから送られるメッセージが入ってきたら破棄する
      • DHCPOFFER, DHCPACKなど
    • untrustedポートに、通常DHCPクライアントから送られるメッセージが入ってきたら、攻撃の疑いのある場合破棄する
      • DHCPDISCOVERなど
    • trustedポートは素通り

A Sample Attack: A Spurious DHCP Server

f:id:wand_ta:20200623084040p:plain

DHCP Snooping Logic

f:id:wand_ta:20200623084231p:plain

  • untrustedポートに入ってくるフレームを検査する
    • 通常サーバーから送られるメッセージ: 破棄
      • OFFER, ACK
    • 通常クライアントから送られるメッセージ:
      • DISDOVER,REQUESTはMACアドレスをチェックする
      • RELEASE,DECLINEはinterface,IPアドレスDHCP Snooping binding tableとを突き合わせる
        • 悪いclientによって勝手にIPアドレスが返却されないよう
        • DHCP Snooping binding tableはleaseのたびに更新

Filtering DISCOVER Messages Based on MAC Address

  • 攻撃
    • IPアドレスプール枯渇攻撃
      • 悪いclientがCHADDR(client hardware address)フィールドを詐称して大量のREQUESTを送りつけ、IPアドレスをすべてleaseしてしまう
  • 対策
      • DISDOVER,REQUESTについてはIEEE802.3 Frameのsource MACフィールドと照合して、攻撃の疑いのあるフレームを破棄する

Filtering Messages that Release IP Addresses

  • 攻撃
  • 対策
    • RELEASE,DECLINEについてはDHCP Snooping binding tableとの照合を行う
    • DHCP Snooping binding table
      • どのMAC,VLAN,interfaceのデバイスにどのIPアドレスをリースしました、というテーブル
      • 異なるinterfaceからのRELEASE等については破棄する

DHCP Snooping Configuration

Configuring DHCP Snooping on a Layer 2 Switch

f:id:wand_ta:20200626044702p:plain

  • 設定
Switch(config)#ip dhcp snooping vlan 1
Switch(config)#no ip dhcp snooping information option
Switch(config)#interface g0/1
Switch(config-if)#ip dhcp snooping trust
  • DHCP Snoopingの状態確認
Switch#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
1
Insertion of option 82 is disabled
Option 82 on untrusted port is not allowed
Verification of hwaddr field is enabled
Interface                  Trusted    Rate limit (pps)
-----------------------    -------    ----------------
GigabitEthernet0/1         yes        unlimited       
FastEthernet0/1            no         unlimited       
FastEthernet0/2            no         unlimited       
  • Option 82 on untrusted port is not allowed
    • no ip dhcp snooping information option が反映されている
  • 何これ
    • DHCP relay agentがbroadcastをunicastに詰め替えるときに付与されるフィールド
      • RFC3046
    • L3SWのときに有効にすべき設定
    • 今回はL2SWなので切る
  • DHCP Spoofingして動作検証してみる

f:id:wand_ta:20200626044716p:plain

  • DHCP Snoopingを設定していないとき

from PC0

C:\>ipconfig /renew

   IP Address......................: 10.0.1.53
   Subnet Mask.....................: 255.255.255.0
   Default Gateway.................: 10.0.1.49
   DNS Server......................: 255.255.255.252
C:\>ipconfig /renew

   IP Address......................: 10.0.1.53
   Subnet Mask.....................: 255.255.255.0
   Default Gateway.................: 10.0.1.1
   DNS Server......................: 255.255.255.252

Limiting DHCP Message Rates

  • DHCP snoopingは汎用CPUを食うのでそれ自体が攻撃対象になりうる
  • この対策として、DHCPのレートリミット機能がある
    • switch-port securityよろしく、portをerr-disabledにする
Switch(config-if)#ip dhcp snooping limit rate 10
Switch(config-if)#int f0/1
Switch(config-if)#ip dhcp snooping limit rate 2
Switch(config-if)#int f0/2
Switch(config-if)#ip dhcp snooping limit rate 2
Switch#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
1
Insertion of option 82 is disabled
Option 82 on untrusted port is not allowed
Verification of hwaddr field is enabled
Interface                  Trusted    Rate limit (pps)
-----------------------    -------    ----------------
FastEthernet0/2            no         2               
FastEthernet0/1            no         2               
GigabitEthernet0/1         yes        10              
  • errdisable recovery global configコマンドで自動復旧も設定できるらしいがPacket Tracerでは動作しなかった

英語

  • backdrop
    • 背景
  • spurious
    • 偽の
      • legitimate(正当な)の対義のように用いられている

CCNA試験対策 下巻ch6: Implementing Switch Port Security

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Port Security Concepts and Configuration

  • switchのポートごとに、Ehternetフレームのsource MAC addressに基づいて機器の接続を制限する

Configuring Port Security

f:id:wand_ta:20200622080653p:plain

static

SW1(config)#interface f0/1
SW1(config-if)#switchport mode access
SW1(config-if)#switchport port-security
SW1(config-if)#switchport port-security mac-address 0200.1111.1111
SW1(config-if)#description static

sticky

  • staticでは大量の機器を登録するのが大変なときに使う
SW1(config-if)#interface f0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport port-security
SW1(config-if)#switchport port-security mac-address sticky
SW1(config-if)#description sticky
  • switchport port-security mac-address sticky設定直後
SW1#show running-config 
...
interface FastEthernet0/2
 description sticky
 switchport mode access
 switchport port-security
 switchport port-security mac-address sticky 
!
...
  SW1#show running-config 
  ...
  interface FastEthernet0/2
   description sticky
   switchport mode access
   switchport port-security
   switchport port-security mac-address sticky 
+  switchport port-security mac-address sticky 0200.2222.2222
  !
  ...
  • startup-configには反映されないので適宜copy running-config startup-configする必要がある

dynamic

SW1(config-if)#interface f0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport port-security
SW1(config-if)#description dynamic

SW1(config-if)#interface f0/4
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport port-security
SW1(config-if)#switchport port-security maximum 8
SW1(config-if)#description maximum 8
  • 最大接続可能台数で縛る
    • デフォルト1
    • 接続可能な機器は動的にきまる
  • VoIPの場合は2を設定する
    • 電話で1 (voice)、その先のPCで1 (access)
  • EtherChannelの場合は、物理interfaceではなくport channelに対してmaximumを設定する

Verifying Port Security

SW1#show port-security interface f0/1
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 1
Configured MAC Addresses   : 1
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 0200.1111.1111:1
Security Violation Count   : 0
  • stickyの場合、stickyで設定されたMACアドレス数が集計される
SW1#show port-security interface f0/2
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 1
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 1
Last Source Address:Vlan   : 0200.2222.2222:1
Security Violation Count   : 0
  • dynamicの場合
SW1#show port-security interface f0/4
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 8
Total MAC Addresses        : 5
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 00E0.B05A.6D01:1
Security Violation Count   : 0

Total MAC Addresses : 5

  • 【疑問点】PCは4台しか繋いでいないのだが…
    • CDPか何かでのトラフィックでswitchのぶんも数えられている?詳細不明

Port Security MAC Addresses

Switch#show mac address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0030.a3a5.4904    DYNAMIC     Fa0/1
  • TypeはDYNAMICとなる
  • 対して、port securityを設定した場合:
SW1#show mac address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0001.438c.c589    STATIC      Fa0/4
   1    0002.1730.086b    STATIC      Fa0/4
   1    0003.e45c.894a    STATIC      Fa0/4
   1    0030.a3a0.a16b    STATIC      Fa0/4
   1    00e0.b05a.6d01    STATIC      Fa0/4
   1    0200.1111.1111    STATIC      Fa0/1
   1    0200.2222.2222    STATIC      Fa0/2
   1    0200.3333.3333    STATIC      Fa0/3
SW1#show mac address-table dynamic 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  • MACアドレステーブルは全部STATICになる
    • たとえstickyやdynamicを設定したとしても

Port Security Violation Modes

  • port securityのルールが破られたときにどうするか設定できる
Protect Restrict Shutdown(デフォルト)
トラフィックを破棄 o o o
ログとSNMPメッセージ送出 x o o
当該interfaceをshutdown x x o

Port Security Shutdown Mode

  • f0/3 (dynamic, maximum 1) のところに2台繋いでみる

f:id:wand_ta:20200622081142p:plain

%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to administratively down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
  • f0/3がdown downになる
SW1#show ip interface brief 
Interface              IP-Address      OK? Method Status                Protocol 
FastEthernet0/1        unassigned      YES manual up                    up 
FastEthernet0/2        unassigned      YES manual up                    up 
FastEthernet0/3        unassigned      YES manual down                  down 
FastEthernet0/4        unassigned      YES manual up                    up 
FastEthernet0/5        unassigned      YES manual down                  down 
...
  • ステータスはerr-disabled
SW1#show interfaces f0/3 status
Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/3                        err-disabled 1          auto    auto  10/100BaseTX
  • port-securityルール違反の統計情報も見られる
SW1#show port-security 
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
               (Count)       (Count)        (Count)
--------------------------------------------------------------------
        Fa0/1        1          1                 0         Shutdown
        Fa0/2        1          1                 0         Shutdown
        Fa0/3        1          0                 1         Shutdown
        Fa0/4        8          1                 0         Shutdown
----------------------------------------------------------------------
SW1#show port-security interface f0/3
Port Security              : Enabled
Port Status                : Secure-shutdown
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 0
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 000A.418E.D86B:1
Security Violation Count   : 1
  • err-disabled状態から復旧するには当該interfaceで shutdown/no shutdown

Port Security Protect and Restrict Modes

SW1(config)#int f0/1
SW1(config-if)#
SW1(config-if)#switchport port-security violation protect
  • f0/1に、許可されているMACアドレス以外の機器を繋いでみる

f:id:wand_ta:20200622081346p:plain

  • protectモードを設定したので、port-securityルール違反のトラフィックは破棄しつつ、interfaceはup-upのままとなる
  • PC5 (172.16.1.51)からPC0(172.16.1.3)へpingを試みる
Pinging 172.16.1.3 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 172.16.1.3:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
  • Switch0 f0/0でブロックされるので到達しない
  • Server0 (172.16.1.1)からPC0(172.16.1.3)にpingは通る
C:\>ping 172.16.1.3

Pinging 172.16.1.3 with 32 bytes of data:

Reply from 172.16.1.3: bytes=32 time=1ms TTL=128
Reply from 172.16.1.3: bytes=32 time<1ms TTL=128
Reply from 172.16.1.3: bytes=32 time<1ms TTL=128
Reply from 172.16.1.3: bytes=32 time<1ms TTL=128

Ping statistics for 172.16.1.3:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • Switch0を経由しないPC5 -> Server0は通る
C:\>ping 172.16.1.1

Pinging 172.16.1.1 with 32 bytes of data:

Reply from 172.16.1.1: bytes=32 time<1ms TTL=128
Reply from 172.16.1.1: bytes=32 time<1ms TTL=128
Reply from 172.16.1.1: bytes=32 time=3ms TTL=128
Reply from 172.16.1.1: bytes=32 time<1ms TTL=128

Ping statistics for 172.16.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 3ms, Average = 0ms

CCNA試験対策 下巻ch5: Securing Network Devices

https://www.ciscopress.com/store/ccna-200-301-official-cert-guide-volume-2-9781587147135www.ciscopress.com


Securing IOS Passwords

  • AAAサーバがあればそれを使いましょう
  • 以下、ない場合の話

note

  • transport input sshtelnet禁止、sshのみ許可することを検討しよう
    • デフォルトall
    • telnetは平文のパスワードが流れてしまう

Encrypting Older IOS Passwords with service password-encryption

  • passwordで設定したパスワードはconfig内に平文で保存される
sw2#show running-config | section line vty 0
line vty 0
 password Cisco
 login
  • service password-encryption でconfig内のパスワードを暗号化できる
sw2(config)#service password-encryption
sw2(config)#end

%SYS-5-CONFIG_I: Configured from console by console

sw2#show running-config | section line vty 0
line vty 0
 password 7 0822455D0A16
 login
sw1>telnet 10.0.0.2
Trying 10.0.0.2 ...Open


User Access Verification

Password: (cisco)
sw2>
  • ただし、簡単に復号できてしまい、強度はよろしくない

Encoding the Enable Passwords with Hashes

  • enable passwordの代わりにenable secret使え

Interactions Between Enable Password and Enable Secret

  • enable passwordenable secret両方設定した場合、enable secretが勝つ
sw2(config)#enable password hoge
sw2(config)#enable secret piyo
sw2(config)#^Z
sw2#
%SYS-5-CONFIG_I: Configured from console by console

sw2#
sw2#show running-config | section enable
enable secret 5 $1$mERr$8uVJh5HjzLjx/K599zVX00
enable password 7 082943490C
sw2#exit

sw2>enable
Password: (piyo)
sw2#

Making the Enable Secret Truly Secret with a Hash

Improved Hashes for Cisco's Enable Secret

sw2(config)#enable secret ?
  0      Specifies an UNENCRYPTED password will follow
  5      Specifies an ENCRYPTED secret will follow
  LINE   The UNENCRYPTED (cleartext) 'enable' secret
  level  Set exec level password
enable secret <type> piyo
enable algorithm-type <algorithm-type> secret piyo
  • 【補】PacketTracerでは後者の書き方はできなかった
  • 指定しない場合デフォルトMD5
<algorithm-type> <type> Algorithm
0 平文
md5 5 MD5
sha256 8 SHA-256
scrypt 9 SHA-256

Encoding the Passwords for Local Usernames

sw2(config)#username foo secret bar
sw2(config)#line vty 0
sw2(config-line)#login local
  • enable同様

Controlling Password Attacks with ACLs

  • access-classACLを設定できる
sw2(config)#line vty 0
sw2(config-line)#access-class 1 in

sw2(config)#access-list 1 permit 10.0.0.1 0.0.0.0
  • SW1 (10.0.0.1)からはtelnet接続可能
sw1#telnet 10.0.0.2
Trying 10.0.0.2 ...Open


User Access Verification

Username: foo
Password: (bar)
sw2>exit
  • SW3 (10.0.0.3)からはtelnet接続不可能
sw3#ping 10.0.0.2

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

sw3#telnet 10.0.0.2
Trying 10.0.0.2 ...Open

[Connection to 10.0.0.2 closed by foreign host]
sw3#
  • access-classコマンドでoutを指定すると、telnet/ssh接続先に基づいてマッチングが行われることに注意

Firewalls and Intrusion Prevention Systems

Traditional Firewalls

  • ACLと似ているところ
  • ACLと異なるところ
  • アプリケーション層の知識ももつ
  • ステートフル
    • 履歴情報に基づいて、「少数のクライアントから大量のTCP接続要求が来ているのでDoSだな」といったことがわかる

Security Zones

  • 「社内から外側へTCPコネクションを張る(initiate)のは許可する」(outbound)
  • 「外側から社内へ張るのは禁止する」(inbound)
  • といったときの「内側」をZone Inside、「外側」をZone Outside という
  • Webブラウザのようなinboundアクセスを許可しなければならないものは Zone DMZ: Demilitarized Zoneに置く
    • DMZから社内へのコネクションは禁止する

Intrusion Prevention Systems (IPS)

  • ACLFirewallとはパケットのフィルタリングロジックが異なる
  • exploit signaturesデータベースに照らして、ロギング、パケットの破棄、追調査などを行う
  • アンチウイルスソフトと似ているが、ネットワーク上でパケットの破棄を行うので、より迅速に新型の脅威に対応できうる

Cisco Next-Generation Firewalls

  • AVC: Application Visibility and Control
    • well-knownポートをふさぐだけでは、攻撃者はポートスキャンを仕掛けて侵入を試みてくる
    • NGFWではポート番号ではなくアプリケーション層のデータに基づいて判断するように
  • Advanced Malware Protection
  • URL Filtering
  • NGIPS (Next-Generation IPS)
    • NGIPS連携

Cisco next-generation IPS

  • AVC
  • Contextual Awareness
    • 従来のIPSではセキュリティイベント通知が膨大すぎて、読むのが困難だった
    • NGFWからホストの情報を受け取り、その情報に基づいて実際に問題となる脆弱性に絞ることで、通知を大幅に減らせるように
  • Reputation-Based Filtering
  • Event Impact Level