changed 5 years ago
Linked with GitHub

CCNA

簡介

  1. 常用按鍵
    • ctrl+shift+6: 中斷程式
    • ?: help
  2. Labs

Switch設定

  1. switch權限
Switch> enable #usermode
password:_
Switch# disable #privilege mode
Switch> exit
(disconnect)
  1. system prompt
Switch# configure terminal #從terminal設定
                  network #遠端連線進來設定
                  memory #設定檔在flash中
Switch(config)#
/* global configuration mode下的command是與整台設備有關*/
Switch(config)# interface fa0/1
Switch(config-if)# 
/* interface configuration mode下輸入的command只影響指定interface */
/* 
    1. interface -> (config-if)
    2. line -> (config-line)
    3. router -> (config-router)
*/
Switch(config-if)# exit
Switch(config)#
  1. 設定機器名稱
Switch# configure terminal
Switch(config)# hostname x1300252
x1300252(config)#
  1. 設定priv-EXEC密碼
Switch(config)# enable secret [password]
/* 這條本身password會被直接加密(MD5) */
/* or */
Switch(config)# enable password [password]
/* 這條指令不做加密 */
/* 加密的指令權限高於未加密的 */
  1. 設定user-EXEC密碼
Switch(config)# line consle 0
                line vty 0 15 /* 0~15 */
/* 透過網路連進來的叫virtual terminal, vty, 編號0~15,最多16個人同時設定 */
Switch(config-line)# password [password]
Switch(config-line)# login #login時要詢問密碼
Switch(config-line)# ^Z /* ctrl-Z */
Switch#
  1. 密碼顯示時加密
Switch(config)# service password-encryption
/*
    1. type5 MD5
    2. type7 SSHA
*/

關掉加密功能,關掉前已經加密的密碼還是會顯示加密過的

Switch(config)# no service password-encryption
  1. IP
Switch(config)# interface vlan 1
Switch(config-if)# ip address [ip] [mask]
Switch(config-if)# no shutdown
/* virtual interface預設是關閉,所以要啟用 */
Switch(config)#
Switch(config)# ip default-gateway [ip]
Switch# show ip interface brief #看各interface的狀況

#range
Switch(config)# interface range ...
Switch(config-if-range)#
  1. 設定檔

    • startup-config: 在flash內,只有開機時會用到
    • running-config: 在RAM內,開機後的設定與修改
    • 查看目前設定狀況
    ​​​​Switch# show running-config
    
    • 將RAM內的設定指令存回flash
    ​​​​Switch# copy running-config startup-config
    ​​​​        write
    
  2. 恢復原廠設定

Switch# erase startup-config
Switch# reload #重新開機
  1. 查看目前作業系統資訊
Switch# show version
  1. 密碼恢復

    • 按住Mode鍵後插上電源後,進入硬體設定
    ​​​​Switch: flash_init
    ​​​​Switch: load_helper
    ​​​​Switch: dir flash #列出flash中的檔案
    ​​​​Switch: rename flash:config.txt flash:config.old
    ​​​​Switch: boot
    ​​​​
    ​​​​Would you like to enter system configuration dialog? [Yes/No]: No
    ​​​​
    ​​​​Switch> enable
    ​​​​Switch# rename flash:config.text.old flash:config.text
    ​​​​Switch# copy flash:config.text system:running-config
    ​​​​Source filename [config.text]?
    ​​​​Destination filename [running-config]?
    ​​​​Press Enter to copy
    ​​​​
    ​​​​S1(config)# enable secret [password]
    ​​​​S1(config)# exit
    ​​​​S1# write
    
  2. 斷線時間,可設在console, vty,預設是10分鐘,0的話是不斷線

    ​​​​S1(config)# line console 0
    ​​​​S1(config-line)# exec 20 30 #分 秒
    
  3. 輸入指令時不會被系統訊息干擾

    ​​​​S1(config-line)# logging syncronize
    

Router設定

  1. 電信用
    • based on 64K channel
      • 64K = 8K Hz * 8bit
    • US
      • T1: 1.544Mbps = 24*64K
      • T2: T1*4
      • T3: T2*7
    • EU
      • E1: 2Mbps
      • E2: E1*4
      • E3: E2*4
  2. 設定hostname
Router# configure terminal
Router(onfig)# hostname R1
R1(config)#
  1. 設定密碼

    • 預設vty介面會有login
  2. 設定 IPv4 Routre Interface

    • router為L3網路設備,因此每個介面都要設
Router(config)# interface [interface]
Router(config-if)# ip address [ipv4] [mask]
Router(config-if)# no shutdown
  1. 設定 IPv4 Routre Interface
  • router為L3網路設備,因此每個介面都要設
Router(config)# interface [interface]
Router(config-if)# ipv6 address [ipv6]/[prefix-length]
Router(config-if)# no shutdown
  1. 兩台router對接
  • DTE: 網路終端 (router)

  • DCE: 電路終端 (ISP控制的機器)

  • 兩台router對接時要由一台來當DCE,設定連線速度

    ​​Router(config)# clock rate [rate(bps)]
    
  • packet tracer 中紅色有時間符號的是專線,先點的那端是DCE

  • 查詢是否為DCE

    ​​Router# show controller
    
  • 連線備註

    ​​Router(config)# description [comment]
    
  1. ping
Router(config)# ping [ipv4]
Router(config)# extended ping #輸入其他選擇
  1. 查看資訊
Router(config)# show interfaces
Router(config)# show arp
Router(config)# ip table
Router(config)# show version
  1. configuration register

    • 共16bit
    • 出場預設是0x2102
    • 最後4個bit決定開機時行為
      • 0000: 檢查硬體後停在ROM
      • 0001: 用ROM中的舊作業系統開機
      • 其他: 正常開機
    • 倒數第7個bit決定開機後的行為
      • 0: 依startup-config執行
      • 1: 忽略start-config
  2. 密碼重設

  • 開機後在IOS完全載入前按ctrl+break中斷

    ​​​​​rommon 1 > confreg 0x2142
    ​​​​​rommon 2 > reset #重開機
    ​​​​​	   - 指令的編號
    ​​​​​####
    ​​​​​Router> enable
    ​​​​​Router# copy startup-config running-config
    ​​​​​/* 將flash內的設定檔複製到RAM中,並一條條執行指令 */
    ​​​​​R1# config terminal
    ​​​​​R1(config)# line console 0
    ​​​​​R1(config-line)# password [password]
    ​​​​​R1(config)# interface [interface]
    ​​​​​R1(config-if)# no shutdown /* 設定各interface後並不會打開 */
    ​​​​​R1(config-if)# exit
    ​​​​​R1(config)# config-register 0x2102
    ​​​​​R1# copy running-config startup-config
    
  1. file system
Router# show file systems
  1. 備份到其他地方
Router# copy running-config tftp
...
  1. 不離開設定介面情況下執行其他介面的指令
Router(config-if)# do [指令] # eg. show ip protocals,原本為 Router# 下的指令

Switching Network and Security

網路規劃

  1. access layer: 提供網路給使用者使用
  2. distribution layer: 流量管控、合併流量
  3. core layer: 高速傳輸、提供備援機制
  4. two-teir: core + access

設備種類

  1. fix
  2. module
  3. stackable: 可同時設定多台設備

Switch LED

  1. SYST: 硬體檢測狀態
  2. RPS: remote/redundent power supply,額外的直流供電模組
  3. STAT: 看每個port上狀態,亮→打開,閃爍→傳送資料中
  4. DUPLX: 看每個port是全雙工(亮)、半雙工(暗)
  5. SPEED: 看每個port的速度
  6. PoE: 看是否有提供網路供電的功能
  • 3~4要用mode按鍵切換

雙工

  1. 10M~100M只用到四根接腳

  2. Cat5→100M、Cat5E→155M、Cat6→250M

  3. 1000M的話四跟線一定都要同時使用,因此不可能為半雙工

  4. 兩端都要是auto才能自動偵測,當自動偵測測不出來時預設會是半雙工

  5. 兩端設定不一時,碰撞率會提高

  6. siwtch雙工模式

Switch(config)# interface fa0/2
Switch(config-if)# duplex auto #設定雙工模式
						  full
						  half
Switch(config-if)# speed auto
						 10
						 100

Auto-MDIX

  1. 偵測RX/TX,自動調整
Switch(config)# interface fa0/2
Switch(config-if)# mdix auto
  1. 查看設備是否支援
Switch# show controllers ethernet-controller

交換器基本觀念

  1. MAC address table: MAC-port
  2. CAM: content addressable memory
  3. 目的地未知的話會做flooding,往來源外的所有port發封包探測
  4. 目的地已知且與來源不同做forwarding
  5. 目的地已知且與來源相同做filtering
  6. switch forwarding mathod:
    • store and forward: 根據ethernet frame 中的FCS檢查沒問題後,根據資訊送出去
    • cut through: 讀完必要資訊後就立刻送出
      • fast forward: 只讀到目的地卡號就送出
      • fragment free: 解決發生碰撞的可能性,收完64byte,確定不會發生碰撞再送出封包
      • 支援限制: 所有port速度都要相同
  7. ethernet frame, 64~1518byte
    1. 8byte preamble: 10101011(提醒資料進來了)
    2. 6byte目的網卡
    3. 6byte來源網卡
    4. 2byte type/length
    5. L3
    6. 4byte FCS: 檢查碼

IOS Command

  1. IOS Command
Switch# show history #最近十條指令
Switch# show mac address-table
  1. show interface
    1. 第一個up→L1,第二個up→L2
    2. L2 down:可能為兩端frame封裝格式不一
    3. late collision: 網路線太長,傳到64byte才偵測到碰撞

Switching Security

SSH

  1. 確認有沒有支援

    ​​​Switch# show ip ssh
    
  2. 設domain name,因為要用hostname與DNS產生金鑰,所以hostname也不能是預設值

    ​​​Switch# config terminal
    ​​​Switch(config)# ip domain-name [domain name]
    ​​​Switch(config)# hostname S1
    ​​​S1(config)# crypto key generate rsa
    
  3. 設定使用者帳號密碼

    ​​​S1(config)# username [username] password [password]
    ​​​								secret [password]
    
  4. 限制只能用SSH連線

    ​​​S1(config)# line vty 0 15
    ​​​S1(config-line)# login local #有人進來要檢查,並根據local的帳密檢查
    ​​​S1(config-line)# transport input ssh
    ​​​								 ssh telnet #ssh優先,不能用時才能用telnet
    
  5. 刪掉金鑰

    ​​​S1(config)# crypto key zerolize rsa
    
  • fa0/1-24
    • 前面的0是模組編號
    • 後面是port編號
    • range的指令不能跨模組
    • 早期的IOS減號前面要空白

Storm Control

  1. 偵測到這個port有問題,就先關掉,避免影響整個網路
  2. 一般: 利用threshold
Switch(config)# interface [interface]
Switch(config-if)# storm-control broadcast level [lv-high (lv-low)]
								 multicast bps [bps-high (bps-low)] 
								 unicast   pps [pps-high (pps-low)]
Switch(config-if)# storm-control action shutdown
										trap # 通知管理者

Protected Port

  1. 同台switch的protected port不能互相交換資料
Switch(config)# interface [interface]
Switch(config-if)# swtichport protected

Port Blocking

  1. 預設會flood未知目的的封包
  2. block unknown unicast and multicast
Switch(config)# interface [interface]
Switch(config-if)# swtichport block multicast
									unicast

Port Security

  1. port只能讓某個MAC address使用

  2. port最多只能學習多少個網卡卡號

  3. static secure MAC addr

    ​​​Switch(config-if)# switchport mode access # 下面接的是電腦而不是switch
    ​​​Switch(config-if)# switchport port-security # 啟用port security的功能
    ​​​Switch(config-if)# switchport port-security mac-address [MAC]
    
  4. dynamic secure MAC addr(預設): 第一個學到的

    ​​​Switch(config-if)# switchport mode access
    ​​​Switch(config-if)# switchport port-security
    
  5. sticky secure MAC addr: 學習時會自動產生指令存到running config

    ​​​Switch(config-if)# switchport mode access
    ​​​Switch(config-if)# switchport port-security
    ​​​Switch(config-if)# switchport port-security mac-address sticky
    
  6. 學到超過一個MAC

    1. protect: 新增加的不能用,原來的使用者可以繼續用
    2. restrict: 同protect,但會有超過的紀錄
    3. shutdown
      • 預設
      • 管理者要恢復要先下shutdown,再下no shutdown
    ​​​Switch(config-if)# switchport port-security violation protect | restrict | shutdown
    
  7. 最多可以學到幾個

    ​​​Switch(config-if)# switchport port-security maximum [num]
    
  8. 查看設定

    ​​​Switch(config)# show port-security interface [interface]
    

VLAN Trunk and VLAN routing

VLAN

  1. 對user來說是logical群組

  2. 不同VLAN屬於不同subnetwork

    • 屬於某特定VLAN之介面時,該介面為access mode
  3. type

    1. data VLAN: 一般使用者用的
    2. default VLAN: 沒特別設定時每個port都屬於VLAN1,不能刪掉不能改名
    3. native VLAN:
      • 原生VLAN,只出現在802.1Q
      • STP, CDP, LLDP等switch自己產生的流量或是特殊流量
      • 沒指定就是VLAN1
      • 沒有VLAN tag
    4. management VALN
      • 管理者用的子網路
      • siwtch IP應該設定在management VLAN上
    5. voice VLAN
      • 電話有兩個port,一個對外,一個對內
      • 對switch來說是一般使用者
  4. 創vlan的方法

    1. config terminal下打vlan [num]
    2. vlan database
    3. switchport access vlan [num],當不存在時會自己創一個
  5. 查看vlan

    • 最多4096個,normal range 1~1001 extended range 1001~
    ​​​Switch# show vlan (brief)
    
  6. vlan設定檔vlan.bat放在flash中

  7. creating a VLAN

    ​​​Switch(config)# vlan [vlan-id], [vlan-id]-[vlan-id] #range
    ​​​Switch(config-vlan)# name [vlan-name]
    ​​​Switch(config-vlan)# end
    
  8. 設定VLAN所屬的port

    ​​​Switch(config)# interface [int] #可用range
    ​​​Switch(config-if)# switchport mode access #optional, but strongly recommended 
    ​​​Switch(config-if)# switchport access vlan [vlan-id]
    ​​​Switch(config-if)# end
    ​​​
    ​​​Switch(config-if)# no switchport access vlan [vlan-id] #改成vlan1的port
    
  9. 刪除設定

    ​​​Switch# delete vlan.dat
    

VLAN Trunk

  1. TRUNK介面透過tagging技術(1Q or ISL)可傳遞不同VLAN的流量

    • frame 加入 802.1Q tag
    • frame 移除 802.1Q tag
    • TAG
      • type
      • user priority
      • canonical format id
      • VLAN ID
  2. 設定trunk

    • 進入DTP mode
    ​​​Switch(config)# interface [int] #可用range
    ​​​Switch(config-if)# switchport mode trunk
    ​​​Switch(config-if)# switchport trunk native vlan [id] #設定native vlan
    ​​​Switch(config-if)# switchport trunk allowed vlan [list] #可由trunk送出去的vlan
    
  3. 常見trunk的問題

    • native vlan mismatch

    • trunk mode mismatch

    • allowed vlans on trunks

VLAN Trunking Protocal

  1. 多部switch間維護VLAN資料不容易

    • 用於自動更新VLAN DB

    • 根據版本號最大者替代可能造成問題

    • 版本號被歸零

      • 設定domain
      • 設定transparent mode
  2. 查看

    • pruning mode: 沒必要的資訊不會傳遞出去
    • Traps Generation: vtp traps 是否要送給管理者
    • V2 mode: disable→v1, enable→v2
    ​​​Switch# show vtp status
    
  3. VTP設定

    • 中間隔著transparent也會更新
    ​​​Switch(config)# vtp mode server # default,新增、修改、刪除,沒有限制只能一台
    ​​​		 				 client # 一切根據server,不能修改增刪
    ​​​		 				 transparent # 自我管理
    
  4. VTP環境,同domain下才能交換,沒設的收到會自動學習同步

    ​​​Switch(config)# vtp domain [name]
    
  5. VTP版本

    • 預設v1,可支援到v2
    • 若收到v2的訊息會自動升級為v2
    • 收到v3的訊息不會自動升級
    ​​​Switch(config)# vtp version 1
    ​​​							2
    

dynamic trunking protocal, DTP

  1. 為了自動辨別介面是否需要成為trunk介面

    • DTP on: manually設定為trunk

    • DTP desirable: 自動偵測

    • DTP auto: 被動偵測,default

    • DTP off: 關閉DTP

VLAN routing

  1. VLAN間需要靠L3設備轉送

  2. 三種方法

    • Legacy inter-VLAN routing

    • Router-on-a-Stick

      • 要用sub-interface
      ​​​​​R1(config)# interface [if].[subif] #這個subif給某個vlan用
      ​​​​​R1(config-subif)# encapsulation dotlq [vlan-id] (native) # native vlan才要加
      ​​​​​R1(config-subif)# ip address [ip] [mask]
      ​​​​​...
      ​​​​​R1(config)# interface [if]
      ​​​​​R1(config-if)# no shutdown # 最後在實體interface下這條指令
      
    • Layer 3 switching using SVIs

      • 要記得啟用L3功能
      • 用Switch Virtual Interface, SVI來轉送封包
      • native vlan設在trunk
      ​​​​​S1(config)# interface [if]
      ​​​​​S1(config-if)# switchport trunk encapsulation dotlq
      ​​​​​S1(config-if)# switchport mode trunk
      ​​​​​S1(config-if)# switchport trunk native vlan [id]
      ​​​​​S1(config-if)# ip routing # 啟用L3功能
      ​​​​​S1(config)# interface vlan 10
      ​​​​​S1(config-if)# ip address [ip] [mask]
      

L2 loop

  1. 三個問題

    • mac address table不穩定
    • 收到重複的frame
    • 廣播風暴
  2. 解決辦法

    • 802.1d STP
    • 802.1w RSTP: 主動送出proposal,鄰居回覆agreement,藉此快速判別網路狀況
    • 802.1s MSTP/MST: group VLAN一起計算
  3. STP:

    1. 透過BPDU (Bridge Protocal Data Unit) 選出root bridge (最小BID)
      • BID, Birdge ID:
        • 16bit priority+48bit mac addr
        • 4bit priority+12bit VLAN ID+48bit mac addr
    2. 非root之switch選出root port
      • 根據到root bridge之最小累積path cost
      • 相同path cost則以鄰居BID決定,相同BID則以port priority決定
      • cost:
        • 10Mbps: 100
        • 100Mbps: 19
        • 1000Mbps: 4
    3. 每個link選出一個designated port
      • 根據link兩端switch的哪個到root的cost比較小,相同時比較BID
    4. 非root port或designated port,就變成non-designated port (blocking)
    5. 超過20秒沒收到鄰居的資料,就判定有問題
  4. port state:

    1. blocking
    2. listening
    3. learming: 不送封包,但會學習mac address
    4. forwarding
    5. disabled
  5. 指令

    1. 修改cost值

      ​​​​​​S1(config-if)# spanning-tree cost [value]
      ​​​​​​S1(config-if)# no spanning-tree cost [value] #改回default val
      
    2. 查看相對資訊

      ​​​​​​S1# show spanning-tree
      ​​​​​​VLANxxxx
      ​​​​​​#root資料
      ​​​​​​....
      ​​​​​​#自己的資料
      ​​​​​​....
      ​​​​​​#interface資料
      ​​​​​​....
      
    3. RSTP的edge port是個不接其他switch的switch port,因此可以link起來後馬上加入spanning tree,但可能會造成其他問題

      ​​​​​​S1(config-if)# spanningtree portfast
      
      1. BPDU filter: 啟用後收到BPDU後取消PortFast的功能
      2. Uplink fast: forward delay調到最小的7秒,並發出訊息更新其他switch 的mac table

EtherChannel

EtherChannel

  1. 把多個線併起來變成邏輯上的一個port

  2. 特色

    1. 增加頻寬
    2. 兩邊設定要相同,例如速度、full duplex、vlan、允許通過的vlan
    3. 不可以跨交換器,如兩個接到A switch,四個接到B switch,這樣變成vPC
  3. PAgP

    • Cisco專屬
    • 每30秒送一次PAgP packet
    • mode
      • on: 直接啟動
      • desirable: 主動,送測試訊息到對方
      • auto: 被動
  4. LACP

    • 最多8條active link,8條備用link
    • mode
      • on: 強迫
      • active: 主動
      • passive: 被動
  5. 設定

    ​​​S1(config)# interface range fa0/1-3
    ​​​S1(config-if-range)# channel-group [num] mode [mode] # num為1~6
    

FHRP

  1. default gateway只有一個,當跟default gateway間出現問題,會無法連線
  2. 相關技術
    1. HSRP: cisco專屬
    2. VRRP: 共通設定
    3. GLBP: load balancing
  3. 一台active,一台備用,中間有virtual router,觀察active是否活著為利用每三秒送出的hello packet,十秒沒收到備用機才升級為active
  4. v3支援IPv6 and IPv4

HSRP

  1. 版本:

    • v1: 支援group 0~255
    • v2: 支援group 0~4095,mac address會比較大
  2. priorty比較高的就是active router

    • 預設為100,範圍為0~255
    • stanby priority這條指令設定
      • stanby preempt: 會讓最高priority 的routerst當作active
  3. 設定

    ​​​S1(config-if)# standby version 2
    ​​​S1(config-if)# standby [group-id] ip [ip]
    ​​​S1(config-if)# standby [group-id] priority [val]
    ​​​S1(config-if)# standby [group-id] preempt
    
  4. Cisco專屬

VRRP

GLBP

  1. load balancing
  2. 多台機器一起服務
  3. Cisco專屬

Power over Ethernet

  1. 網路線也是電源線

  2. 相關設定

    ​​​power inline
    ​​​power inline never # disable
    ​​​show power inline
    

Port Mirroring

  1. port的流量複製一份傳到另外一個port

  2. switch port analyzer, SPAN

  3. remote SPAN: 複製一份丟掉另外一個switch的某個port上

  4. local SPAN設定

    ​​​S1(config)# monitor session [num] source [interface | vlan]
    ​​​S1(config)# monitor session [num] destination [interface | vlan]
    
  5. remote SPAN設定: 利用vlan

    ​​​S1(config)# vlan 100
    ​​​S1(config-vlan)# name RSPAN
    ​​​S1(config-vlan)# remote-span
    ​​​S1(config-vlan)# exit
    ​​​S1(config)# monitor session [num] source [interface | vlan]
    ​​​S1(config)# monitor session [num] destination remote vlan 100
    ​​​
    ​​​S1(config)# vlan 100
    ​​​S1(config-vlan)# name RSPAN
    ​​​S1(config-vlan)# remote-span
    ​​​S1(config-vlan)# exit
    ​​​S1(config)# monitor session [num] destination [interface | vlan]
    ​​​S1(config)# monitor session [num] source remote vlan 100
    

Static Routing, Dynamic Routing & RIP

router

  1. static

  2. dynamic

    1. IGP, interior gateway protocal (IntraAS, AS內用)
      1. Distance Vector: RIP, EIGRP
      2. Link State: OSPF, ISIS
    2. EGP, exterior gateway protocal (InterAS, AS間用)
      1. Path Vector (policy base): BGP
    • AS: 自治管理系統
  3. metric

    1. RIP: hop-count
    2. EIGRP: bandwidth + delay
    3. OSPF: cost
  4. static route generaion

    1. 下一站ip: 查詢兩次routing table
    2. 送出介面: 查詢一次routing table,但只能接serial介面
    3. 管理距離: 路徑的優先順序,設定後routing table只會有最高的那條路徑
    ​​​Router(config)# ip route [目的網路] [mask] [[下一站ip],[送出介面]]  [管理介面(default=1)]
    
    • default route: 通常是routing table,當在routing table中找不到時,會往這個介面丟
  5. ipv6 routing

    1. ipv6 routing預設是關掉的

    2. 要記得下

      ​​​​​​Router(config)# ipv6 unicast-routing
      

Dynamic Routing

  1. routing 演算法
    1. RIP: BellmanFord
    2. EIGRP: DUAL
    3. OSPF: Dijkstra
  2. RIP
    1. 兩個router間每30秒交換一次資訊
    2. routing loop問題: 當有個網路不通時,router間交換資訊會把到達該網路的hub數一直往上加
    3. 解決方法
      1. Maximum Metric: hop數到達上限(15)時就表示該網路已經掛掉了
      2. Split Horizon: 收到的資訊不能往回傳,只能往其他介面傳
      3. Poison Reverse: 收到的資訊往回傳時hub數改為上限
      4. trigger update: 有問題就直接通知
      5. hold-down timer: 連線斷掉後的一段時間內,收到比原本資訊還差的一律不用

RIP

  1. packet

    • dest MAC
      • FFFF FFFF FFFF
      • 01005E 000009
    • dest IP
      • RIPv1: 255.255.255.255
        • 會干擾所有電腦
      • RIPv2: 224.0.0.9
        • Multicast
    • UDP: port 520
    • RIP
      • 4 byte header
      • 每個route佔20 bytes,最多25route
  2. timer

    • update: 25~30s,避免大家在同一時間update
    • invalid: 180s,這段時間後沒收到update後,會在該條route註明posiably down
    • flush: 240s,invalid後flush timeout後,route刪掉
    • hold-down:180s,180秒內更新rip domain
  3. 路徑 metric 路量值為經過 hub 數

  4. config

    ​​​Router(config)# router rip
    ​​​Router(config-router)# network {A|B|C|D}
    
    • A, B, C, D為標準classful位址寫法,router會自動調整
    • eg. class A,network 10.1.1.5會自動調整為network 10.0.0.0
    • 符合network命令之interface開始交換RIP資訊,並且交換的資訊符合該network範圍
  5. RIPv1 vs RIPv2

    • default為v1

    • v1的route資訊不含mask,因此不支援VLSM/CIDR,收到時只能套用收到介面的mask

    • v2支援認證

    • default是v1, v2都收,v2不收v1的訊息

    • 版本切換

      ​​​​​Router(config-router)# version {1|2}
      
    • 被動介面: 只收不送routing資訊,當interface接的LAN內沒有router時可以用

      ​​​​​Router(config-router)# passive-interface [int]
      
    • 不連續網路問題

      • 兩個相同class的網路中間隔了一個其他class的subnet,RIP封包會自動合併subnet

      • Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →

      • 解決方法

        ​​​​​​​Router(config-router)# version 2
        ​​​​​​​Router(config-router)# no auto-summary
        
        • 新的IOS已經改為default關閉auto-summary
  6. 傳遞default route

    ​​​Router(config)# ip route 0.0.0.0 0.0.0.0 S 0/0/0
    ​​​Router(config)# router rip
    ​​​Router(config-router)# default-information originate
    
  7. 查看資訊

    ​​​Router# show ip protocals 
    

OSPFv2 & OSPFv3

OSPF

  1. 五種封包
    • hello
      • 一般網路每10秒送一次
      • NBMA每30秒送一次
      • dead interval: 4倍時間內沒收到就視為不存在
      • 建立鄰居時兩邊timer時間要一樣
    • database description
    • link state ACK
    • link state request
    • link state update
  2. SPF tree
  3. 順序
    1. 建立鄰居: 互傳hello
    2. 互傳DBD(地圖摘要),要回LSACK
    3. LSR要求細節,LSU回報細節

States

down
init 互相傳送hello packet (每十秒送一次)
two-way 在對方的鄰居中發現自己後進入這個狀態
exStart 決定誰要先送DBD packet,有最高router ID的最先
exchange 交換DBD,收到後回傳LSAck
loading 需要更多細節時向對方傳LSR,對方會回LSU,收到要回LSAck
full
  • 比較
    • STP:
      • L2
      • BID: 16 bits,priority+MAC,越小越好
      • 有更小的BID會被取代
    • DR/BDR:
      • L3
      • priority+ router ID
        • priority:
          • 8 bit,default=1,越大越好
          • serial介面會是0,不想當DR/BDR
        • router ID: 手動設定 > loopback > up狀態介面IP最大的
      • DR不會被取代,當DR掛了BDR會成為DR,剩下的再選出新的BDR
      • 只有LAN的環境才要選DR/BDR

OSPFv2

Router(config)# router ospf [process-id]
Router(config-router)# router-id [A, B, C, D] # ipv4 class, optional
Router(config-router)# network [網路位址] [wildcard-mask] area [area-id]
Router(config-router)# passive-interface [介面]
Router(config-router)# default-infomation originate
  • process-id為1~65535,本地有效,router間不需相同

  • router ID 為唯一識別,不能重複,優先順序為

    • 利用router-id命令指定

    • loopback介面之 IP 最大值 (開機自動up)

      • loopback介面config

        ​​​​​​Router(config)# interface loopback [num] # 從0開始
        
    • active狀態介面之 IP 最大值 (不見得會是預期的)

    • 已經設好的router ID 再設定一次不一定會更改,可以重新執行ospf process來更改

      ​​​​Router# clear ip ospf process 
      
  • 網路位址:

    • RIP為classful IP,會有路由問題
    • 範圍由wildcard決定
  • wildcard-mask

    • 可接受輸入netmask,IOS會自己轉
    • 0 是 match,1 是 ignore
  • 只收資訊不送出的被動介面設定 (passive-interface) 與 RIP, EIGRP相同

  • 將default route利用 Routing Protocal 轉送出去,設定與 RIP 相同

    • EIGRP使用 redistribute static命令
  • 路徑 metric 度量值為 cost,計算方式為 \(10^8/bps\)

    • 10 Mbps cost = 10

    • 100 Mbps 以上 cost = 1

    • 修改參考頻寬 (\(10^8\))

      ​​​​Router(config-router)# auto-cost reference-bandwidth [Mbps]
      
      • ex: auto-cost reference-bandwidth 1000, cost計算變成 \(10^9/bps\)
    • serial介面之頻寬計算可能與實際不符 (租的頻寬跟預設的1544K可能不一樣)

      ​​​​Router(config-if)# bandwidth Kbps
      
    • 可以直接在網路介面上指定cost

      ​​​​Router(config-if)# ip ospf cost [cost]
      
  • 檢查鄰居

    ​​Router# show ip ospf neighbor
    
    • 成為鄰居的條件:
      • 位於相同area
      • hello間隔時間一樣
      • link type 一樣

OSPFv3

Router(config)# ipv6 unicast-routing # ipv6流量才會轉送
Router(config)# ipv6 router ospf [process-id]
Router(config-rtr)# router-id [A,B,C,D] #ipv4
Router(config-rtr)# interface 介面
Router(config-if)# ipv6 ospf [process-id] area [num]
  • router ID是32 bit,一定要直接指定

  • ipv6 default routing

    ​​ipv6 route ::/0 {下一站ip | 送出介面}
    
  • hello packet來源是link local address

  • link-local address

    ​​Router(config)# int {interface}
    ​​Router(config-if)# ipv6 address {addr} link-local
    

Multi-Area OSPF

  1. area: 差異在跟其他area交換資料的種類

    • stub area: 網路末端,會有一台router接backbone,不會再接往其他area

      ​​​​​area [num] stub
      
    • totally stubby area: 只保存area內的資料跟default route

    • not so stubby area, NSSA: 會皆非OSPF area,外部路由資訊可以傳遞進來

    • NSSA totally stubby area

Access Control Lists

  • 一系列的IOS指令
  • 種類
    • Standard ACL: 只檢查source address,只檢查L3 IP
    • Extended ACL: 可檢查source/destinaiton L3/L4資訊,ex: port, protocal
    • Complex ACL:
      • 動態ACL: 身分認證,有認證才能用,時間過了會擋掉
      • 反射ACL: 連出去回傳的流量可以進來,外面要連進來的擋掉
      • time-based ACL
  • implicit deny: 不符合才會繼續比對下一條,沒有任何條件符合的話會被deny
  • inbound: 進到router的traffic
  • outbound: router送出的traffic
  • router執行順序: NAT -> outbound ACL
  • wildcard mask:
    • bit為0的要符合,bit為1的don't care
    • n個 ip 要合併,n 必須為 \(2^x\),第一個 ip 必須能被 n 整除
    • host: 0.0.0.0
    • any: 255.255.255.255
  • Standard ACL離目的地越近越好,Extended ACL離來源越近越好

Standard ACL

  1. 設定

    ​​​Router(config)# access-list {1-99|1300-1999} remark 註解文字
    ​​​                                             permit 來源位置條件 [log] 
    ​​​                                             deny
    ​​​Router(config)# interface [interface]
    ​​​Router(config-if)# ip access-group num {in|out} # 採用某個ACL 
    
    • 早期 IOS 1-99 是給 Standard ACL用的,100-1200 是給 Extended ACL

    • 來源位址條件

      • IP address wildcard
      • host IP address
      • any
    • Log: 比對成功要記錄下來

    • 刪掉ACL: 只能刪掉整個 list,不能刪掉某條 rule

      ​​​​​Router(config)# no access-list num
      
    • 修改時最好先關掉 ip access-group

    • 查詢

      ​​​​​Router# show access-lists
      
  2. named ACL: 可以刪掉裡面某條 rule,或是插入 rule

    ​​​Router(config)# ip access-list {standard|extended} name
    ​​​Router(config-standard)# {remark|permit|deny} ...
    ​​​or
    ​​​Router(config-extended)# {remark|permit|deny} ...
    
  3. 插入: 先查詢目前 rule 的編號狀態,再用新的編號插入

    ​​​Router(config-standard)# num {remark|permit|deny} ...
    
  4. 保護 vty

    ​​​Router(config)# line vty num
    ​​​Router(config-line)# access-class num {in | vty-also | out}
    

Extended ACL

  1. 設定

    ​​​R1(config)# access-list {100-199|2000-2699} remark 註解文字
    ​​​                                            permit protocal 來源位置 目的條件 [log] 
    ​​​                                            deny
    
    • 各 protocal 的來源/目的條件:

      • ip: ip wildcard host IP | any

      • tcp/udp: port 編號通常只出現在一邊

        ​​​​​​​{ ip wildcard | host IP | any } { gt | lt | eq | neq } port # port條件沒設定的話就是全部
        
      • icmp

        ​​​​​​​{ ip wildcard | host IP | any } { echo | echo-reply }
        
Select a repo