網頁

2012年3月11日 星期日

CCNA學習筆記(七)

IPv6
3.4*10^38 個IP
優點:強調隨插即用、具備可移動性、安全性,routing效率提升。
以Anycast與Multicast,取代IPv4的Broadcast。

IPv6位址表示法
000A:3600:0000:0000:74e5:0bff:fe3c:8899/64
    首碼(Perfix)                       介面ID        首碼長度
可區分為兩大部分:首碼(Perfix)+介面ID
Perfix:長度大概由3~64bit,/XX就可知道該位址長度為多少bit。
介面長度ID:128減去perfix長度。

EUI-64位址表示法
從Router取的64bits的首碼,再利用本身MAC Address(48bits)中間再插入FFFE(16bits)。

IPv6 Routing

RIPng
功能與RIP或RIP2大致相同,只是RIP是在Config Mode下設定,RIPng在Interface Mode下設定。

<IPv4>
Router-0(config)#router rip
Router-0(config-router)#network 10.0.0.0
Router-0(config-router)#network 192.168.1.0

<IPv6>

Router-0(config)#ipv6 unicast-routing (必須先開啟IPv6流量轉送功能)
Router-0(config)#int fa0/0
Router-0(config-if)#ipv6 rip ?
  WORD  User selected string identifying this RIP process (識別標籤,同Router設定為一樣)
Router-0(config-if)#ipv6 rip 200 ?
  default-information  Configure handling of default route
  enable               Enable/disable RIP routing
Router-0(config-if)#ipv6 rip 200 enable 
Router-0(config-if)#int fa0/1
Router-0(config-if)#ipv6 rip 200 enable 
(不用像IPv4設定network)



Router-0#sh ipv6 route
IPv6 Routing Table - 6 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route, M - MIPv6
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
       D - EIGRP, EX - EIGRP external
C   2001:1:1:1::/64 [0/0]
     via ::, FastEthernet0/0
L   2001:1:1:1::1/128 [0/0]
     via ::, FastEthernet0/0
R   2001:2:2:2::/64 [120/2]
     via FE80::2E0:F7FF:FE45:BB02, FastEthernet0/1
C   2001:10:10:10::/64 [0/0]
     via ::, FastEthernet0/1
L   2001:10:10:10::1/128 [0/0]
     via ::, FastEthernet0/1
L   FF00::/8 [0/0]
     via ::, Null0



EIGRPv6
<IPv4>
Router-0(config)#router eigrp 10

Router-0(config-router)#network 192.168.1.0 255.255.255.0
Router-0(config-router)#network 10.1.1.0 255.255.255.248

<IPv6>
Router-0(config)#ipv6 unicast-routing (啟動IPv6 unicast-routing)

Router-0(config)#ipv6 router eigrp 20 (設定IPv6 EIGRP,AS=20)
Router-0(config-rtr)#no sh             (EIGRPv6設定好後還要啟動才會生效)
Router-0(config-rtr)#int fa0/0

Router-0(config-if)#ipv6 eigrp 20
Router-0(config-if)#int fa0/1
Router-0(config-if)#ipv6 eigrp 20
(不用像IPv4設定network)



Router-0#sh run

!
!
ipv6 unicast-routing
!

!
ip name-server 0.0.0.0
!

interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
 ipv6 address 2001:1:1:1::1/64
 ipv6 eigrp 20
!
interface FastEthernet0/1
 ip address 10.1.1.1 255.255.255.248
 duplex auto
 speed auto
 ipv6 address 2001:10:10:10::1/64
 ipv6 eigrp 20
!
interface Vlan1
 no ip address
 shutdown
!
router eigrp 10
 network 192.168.1.0
 network 10.1.1.0 0.0.0.7
 auto-summary
!
ipv6 router eigrp 20
 no shutdown 
!
ip classless
!


Router-0#sh ipv6 route 
IPv6 Routing Table - 6 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route, M - MIPv6
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
       D - EIGRP, EX - EIGRP external
C   2001:1:1:1::/64 [0/0]
     via ::, FastEthernet0/0
L   2001:1:1:1::1/128 [0/0]
     via ::, FastEthernet0/0
D   2001:2:2:2::/64 [90/30720]
     via FE80::2E0:F7FF:FE45:BB02, FastEthernet0/1
C   2001:10:10:10::/64 [0/0]
     via ::, FastEthernet0/1
L   2001:10:10:10::1/128 [0/0]
     via ::, FastEthernet0/1
L   FF00::/8 [0/0]
     via ::, Null0







PC>ping 2001:2:2:2::2
Pinging 2001:2:2:2::2 with 32 bytes of data:
Reply from 2001:2:2:2::2: bytes=32 time=30ms TTL=126
Reply from 2001:2:2:2::2: bytes=32 time=19ms TTL=126
Reply from 2001:2:2:2::2: bytes=32 time=100ms TTL=126
Reply from 2001:2:2:2::2: bytes=32 time=22ms TTL=126

OSPFv3
<IPv4>

Router-0(config)#router ospf 10
Router-0(config-router)#network 192.168.1.0 255.255.255.0 area 0
Router-0(config-router)#network 10.1.1.0 255.255.255.248 area 0

<IPv6>

Router-0(config)#ipv6 unicast-routing 
Router-0(config)#int fa0/0

Router-0(config-if)#ipv6 ospf 20 area 0
Router-0(config-if)#int fa0/1
Router-0(config-if)#ipv6 ospf 20 area 0



Router-0#sh run
Building configuration...
!
!
ipv6 unicast-routing
!
!
ip name-server 0.0.0.0

!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
 ipv6 address 2001:1:1:1::1/64
 ipv6 ospf 20 area 0
!
interface FastEthernet0/1
 ip address 10.1.1.1 255.255.255.248
 duplex auto
 speed auto
 ipv6 address 2001:10:10:10::1/64
 ipv6 ospf 20 area 0
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 10
 log-adjacency-changes
 network 192.168.1.0 0.0.0.255 area 0
 network 10.1.1.0 0.0.0.7 area 0
!
ipv6 router ospf 20
 log-adjacency-changes
!

Router-0#sh ipv6 rout
IPv6 Routing Table - 6 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route, M - MIPv6
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
       D - EIGRP, EX - EIGRP external
C   2001:1:1:1::/64 [0/0]
     via ::, FastEthernet0/0
L   2001:1:1:1::1/128 [0/0]
     via ::, FastEthernet0/0
O   2001:2:2:2::/64 [110/2]
     via FE80::2E0:F7FF:FE45:BB02, FastEthernet0/1
C   2001:10:10:10::/64 [0/0]
     via ::, FastEthernet0/1
L   2001:10:10:10::1/128 [0/0]
     via ::, FastEthernet0/1
L   FF00::/8 [0/0]
     via ::, Null0

IPv6轉IPv4通道(IPv6 Over IPv4 Tunnel)
在企業兩端分別架設具有雙重堆疊的Router(IPv4&IPv6),分別幫封包加IPv4標頭與解IPv4標頭,這樣就可以建立出一條穿越IPv4的通道(Tunnel),讓兩端的IPv6封包可以自由地進出。


Router 2

tunnel destination 192.34.1.4
tunnel mode ipv6ip
Router 4
tunnel destination 192.23.1.2
tunnel mode ipv6ip






2012年3月10日 星期六

CCNA學習筆記(六)

使用NAT的缺點
1.增加路徑轉換的延遲。
2.失去對IP來源的可追溯性。
3.導致某些應用程式的通訊失敗的問題。

NAT的類型與使用時機
1.靜態NAT
從Local到Global有著一對一的靜態對應關係。
2.動態NAT
內部一群Local IP與一群外部Global IP做非固定的動態隨機對應,多少Local IP就需相同數量的Global IP,如Global IP數量不足,就會有部分電腦沒有IP使用。
3.超載NAT(Overloading),又稱PAT(Port Address Translation)
多個Local IP,對應到一個Global IP+不同的Port Number,讓多台電腦共用一個Public IP連上Internet。

<靜態NAT>
轉換前

Packet Tracer PC Command Line 1.0
PC>telnet 10.1.1.254
Trying 10.1.1.254 ...Open

Router-2>sh users
    Line       User       Host(s)              Idle       Location
* 67 vty 0                idle                 00:00:00 192.168.1.1

  Interface    User               Mode         Idle     Peer Address

設定

Router-1(config)#ip nat inside source static 192.168.1.1 10.1.1.1
Router-1(config)#ip nat inside source static 192.168.1.2 10.1.1.2
Router-1(config)#ip nat inside source static 192.168.1.3 10.1.1.3
Router-1(config)#int fa0/0

Router-1(config-if)#ip nat inside
Router-1(config-if)#int fa0/1
Router-1(config-if)#ip nat outside

轉換後

PC>telnet 10.1.1.254
Trying 10.1.1.254 ...Open

Router-2>sh users
    Line       User       Host(s)              Idle       Location
  67 vty 0                idle                 00:06:33 192.168.1.1
* 68 vty 1                idle                 00:00:00 10.1.1.1

  Interface    User               Mode         Idle     Peer Address

<動態NAT>
Inside Local 192.168.1.1~254
Inside Global 10.1.1.1~3
1.宣告外部IP的範圍,指定一個pool(IP池),ip nat pool+名稱+起始IP+結束IP+netmask
2.宣告內部IP的範圍,使用ACL,access-list+編號+permit+內部IP範圍(使用wildcard mask)
3.把設定好的ACL指定到設定好的pool,ip nat inside source list+(ACL編號)+pool+(pool名稱)
4.最後在宣告Inside介面與Outside介面,ip nat inside,ip nat outside

設定
Router-1(config)#ip nat pool lobo 10.1.1.1 10.1.1.3 netmask 255.255.255.0
Router-1(config)#access-list 1 permit 192.168.1.0 0.0.0.255 (wildcard mask)

Router-1(config)#ip nat inside source list  ?
  interface  Specify interface for global address
  pool       Name pool of global addresses
Router-1(config)#ip nat inside source list 1 pool lobo

Router-1(config)#int fa0/0
Router-1(config-if)#ip nat inside
Router-1(config-if)#int fa0/1
Router-1(config-if)#ip nat outside
Router-1#sh run
!

interface FastEthernet0/0
 ip address 192.168.1.254 255.255.255.0
 ip nat inside
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.1.1.253 255.255.255.0
 ip nat outside
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 network 10.0.0.0
 network 192.168.1.0
!
ip nat pool lobo 10.1.1.1 10.1.1.3 netmask 255.255.255.0
ip nat inside source list 1 pool lobo
ip classless
!
!
access-list 1 permit 192.168.1.0 0.0.0.255
!
!


結果(使用3台PC,telnet至Router-2)

Router-2#sh users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00
  67 vty 0                idle                 00:00:29 10.1.1.1
  68 vty 1                idle                 00:00:18 10.1.1.2
  69 vty 2                idle                 00:00:08 10.1.1.3


Router-1#sh ip nat statistics
Total translations: 3 (0 static, 3 dynamic, 3 extended)
Outside Interfaces: FastEthernet0/1
Inside Interfaces: FastEthernet0/0
Hits: 33  Misses: 49
Expired translations: 0
Dynamic mappings:
-- Inside Source
access-list 1 pool lobo refCount 3
 pool lobo: netmask 255.255.255.0
       start 10.1.1.1 end 10.1.1.3
       type generic, total addresses 3 , allocated 3 (100%), misses 0

Router-1#sh ip nat translations
Pro  Inside global     Inside local       Outside local      Outside global
tcp 10.1.1.1:1025      192.168.1.1:1025   10.1.1.254:23      10.1.1.254:23
tcp 10.1.1.2:1025      192.168.1.2:1025   10.1.1.254:23      10.1.1.254:23
tcp 10.1.1.3:1025      192.168.1.3:1025   10.1.1.254:23      10.1.1.254:23

<PAT(NAT OverLoad)>

Inside Local 192.168.1.1~254
Inside Global 10.1.1.1
與動態NAT相似,只是pool宣告縮減為單一IP,另外在宣告NAT轉換時,後面加一個overload。

設定
Router-1(config)#ip nat pool robert 10.1.1.1 10.1.1.1 netmask 255.255.255.0
Router-1(config)#access-list 2 permit 192.168.1.0 0.0.0.255
Router-1(config)#ip nat inside source list 2 pool robert overload

Router-1(config)#int fa0/0
Router-1(config-if)#ip nat inside
Router-1(config-if)#int fa0/1
Router-1(config-if)#ip nat outside

Router-1#sh run
Building configuration...


interface FastEthernet0/0
 ip address 192.168.1.254 255.255.255.0
 ip nat inside
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.1.1.253 255.255.255.0
 ip nat outside
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 network 10.0.0.0
 network 192.168.1.0
!
ip nat pool robert 10.1.1.1 10.1.1.1 netmask 255.255.255.0
ip nat inside source list 2 pool robert overload
ip classless
!
!
access-list 2 permit 192.168.1.0 0.0.0.255
!


Router-1#sh ip nat statistics 
Total translations: 3 (0 static, 3 dynamic, 3 extended)
Outside Interfaces: FastEthernet0/1
Inside Interfaces: FastEthernet0/0
Hits: 29  Misses: 12
Expired translations: 0
Dynamic mappings:
-- Inside Source
access-list 2 pool robert refCount 3
 pool robert: netmask 255.255.255.0
       start 10.1.1.1 end 10.1.1.1
       type generic, total addresses 1 , allocated 1 (100%), misses 0

Router-1#sh ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
tcp 10.1.1.1:1025      192.168.1.1:1025   10.1.1.254:23      10.1.1.254:23
tcp 10.1.1.1:1024      192.168.1.2:1025   10.1.1.254:23      10.1.1.254:23
tcp 10.1.1.1:1026      192.168.1.3:1025   10.1.1.254:23      10.1.1.254:23


Router-2#sh users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00
  67 vty 0                idle                 00:00:35 10.1.1.1
  68 vty 1                idle                 00:00:25 10.1.1.1
  69 vty 2                idle                 00:00:10 10.1.1.1


debug ip nat
Router-1#no debug ip nat 
IP NAT debugging is off
Router-1#debug ip nat
IP NAT debugging is on
Router-1#
NAT: s=192.168.1.1->10.1.1.1, d=10.1.1.254 [197]
NAT*: s=10.1.1.254, d=10.1.1.1->192.168.1.1 [213]
NAT: expiring 10.1.1.1 (192.168.1.1) icmp 128 (128)












CCNA學習筆記(五)

Access List

1.按順序的比較,先比較第一行,再比較第二行..直到最後1行
2.從第一行起,直到找到1個符合條件的行;符合以後,其餘的行就不再繼續比較下去
3.默認在每個ACL中最後1行為隱含的拒絕(deny),如果之前沒找到1條許可(permit)語句,意味著封包將被丟棄.所以每個ACL必須至少要有1行permit語句,除非你想想所有數據包丟棄



Access List種類
1.Standard Access List(標準存取清單):使用IP來定義管制來源與目的地。
2.Extended Access List(延伸存取控制清單):使用IP+服務類型(IP+Port Number)來定義管制來源與目的地。

Access List的管制方向
1.Inbound Access List(進入存取清單):封包進入介面,必須先經過Inbound Access List的過濾,符合條件者才能放行。(先處理,再路由)
2.Outbound Access List(離開存取控制清單):封包離開介面,必須先經過Outbound Access List的過濾,符合條件者才能放行。(先路由,再處理)
每個介面的每一個協定的每一個方向,只能指定一個存取清單。

正向列表與負向列表(黑名單與白名單)
1.正向列表:除非在名單中允許的行為,否則其餘行為皆禁止,白名單。
2.負向列表:除非在名單中禁止的行為,否則其餘行為皆允許,黑名單。
Cisco Router預設採正向列表,Router會自動再Access List尾端加一行隱藏的Deny Any,所以凡是你沒有列出的允許行為,預設通通會被禁止,這就是正向列表的設定方式。

Access List編號
1.Standard Access List:1~99、1300~1999
標準ACL,在特權模式下使用命令access-lists [範圍數字] [permit/deny] [any/host].範圍數字為1到99和1300到1999;permit/deny分別為允許和拒絕;any為任何主機,host為具體某個主機(需要跟上IP地址)或某1段
2.Extended Access List:100~199、2000~2699
擴展ACL:命令是access-list [ACL號] [permit/deny] [協議] [源地址] [目標地址] [操作符號] [端口] [log].ACL號的範圍是100到199和2000到2699;協議為TCP,UDP等,操作符號有eq(表等於),gt(大於),lt(小于)和neq(非等於)等等;log為可選,表示符合這個ACL,就記錄下這些日誌

ACL設置要點

1.每個介面,每個方向,每種協議 , 只能設置1個ACL。
2.組織好你的ACL的順序 , 比如測試性的最好放在ACL的最頂部。
3.你不可能從ACL從除去1行 , 除去1行意味你將除去整個ACL , 命名訪問列表(named access lists)例外。
4.默認ACL結尾語句是deny any , 所以你要記住的是在ACL裏至少要有1條permit語句。
5.記得創建了ACL後要把它應用在需要過濾的介面上。
6.ACL是用於過濾經過router的封包 , 它並不會過濾router本身所産生的封包。
7.盡可能的把IP標準ACL放置在離目標地址近的地方 , 盡可能的把IP擴展ACL放置在離源地址近的地方。

Standard Access List語法
<單點設定>
Router-0(config)#access-list 1 permit 192.168.1.1 (允許192.168.1.1,後接有隱藏deny any)
Router-0(config)#int fa0/1 (選擇要套用的介面)
Router-0(config-if)#ip access-group 1 ?
  in   inbound packets
  out  outbound packets
Router-0(config-if)#ip access-group 1 out (套用在Fa0/1介面離開方向)

其他PC被拒絕(如 192.168.1.2)
PC>ping 192.168.2.1

Pinging 192.168.2.1 with 32 bytes of data:

Reply from 192.168.1.254: Destination host unreachable.(路由後,直接丟棄封包)
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.

同上效果
Router-0(config)#access-list 2 permit 192.168.1.1 
Router-0(config)#int fa0/0
Router-0(config-if)#ip access-group 2 in

其他PC(如 192.168.1.2)
PC>ping 192.168.2.1

Pinging 192.168.2.1 with 32 bytes of data:

Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.

Cisco建議:
使用Standard Access List,盡量設定在靠近目的位置。
使用Extended Access List,盡量設定在靠近來源位置。

<網段設定>
此時設定一整段的IP,必須使用Wildcard Mask語法
Router-0(config)#access-list 13 permit 192.168.1.0 0.0.0.127 (允許192.168.1.1~127)
Router-0(config)#int fa0/1 
Router-0(config-if)#ip access-group 13 out

192.168.1.128/24~192.168.1.253/24
PC>ping 192.168.2.1

Pinging 192.168.2.1 with 32 bytes of data:

Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.

同上效果
Router-0(config)#access-list 14 permit 192.168.1.0 0.0.0.127
Router-0(config)#int fa0/0
Router-0(config-if)#ip access-group 14 in

<負向列表單點設定>
Router-0(config)#access-list 15 deny 192.168.1.1(禁止192.168.1.1通過)
Router-0(config)#access-list 15 permit any (允許全部)
Router-0(config)#int fa0/1
Router-0(config-if)#ip access-group 15 out
Router-0(config)#do sh acc
Standard IP access list 15
    deny host 192.168.1.1
    permit any
   (deny any預設隱藏的)
因Cisco Router預設採正向列表,會在ACL最後加上一條隱藏的deny any,為改變此預設行為,所以在ACL後要加上一條permit any,這樣可以把正向列表變更為負向列表。

同上效果
Router-0(config)#access-list 16 deny 192.168.1.1(禁止192.168.1.1通過)
Router-0(config)#access-list 16 permit any (允許全部)
Router-0(config)#int fa0/0
Router-0(config-if)#ip access-group 16 in

<負向列表網段設定>
禁止192.168.1.1~127(192.168.1.0/25)通過
Router-0(config)#access-list 17 deny 192.168.1.0 0.0.0.127
Router-0(config)#access-list 17 permit any
Router-0(config)#int fa0/1
Router-0(config-if)#ip access-group 17 out
Router-0(config-if)#do sh acc
Standard IP access list 17
    deny 192.168.1.0 0.0.0.127
    permit any

同上效果
Router-0(config)#access-list 18 deny 192.168.1.0 0.0.0.127
Router-0(config)#access-list 18 permit any
Router-0(config)#int fa0/0
Router-0(config-if)#ip access-group 18 in

Extended Access List語法
<單點設定>
允許任何電腦存取Server(192.168.2.1)的WWW服務
Router-0(config)#access-list 101 permit tcp any host 192.168.2.1 eq 80
Router-0(config)#int fa0/1
Router-0(config-if)#ip access-group 101 out
Router-0(config-if)#do sh acc
Extended IP access list 101
    permit tcp any host 192.168.2.1 eq www

<網段設定練習>
1.192.168.1.0/25網段可以Ping Server(192.168.2.1)
2.192.168.1.128/25網段可以使用WWW瀏覽Server(192.168.2.1)
3.192.168.1.253可以無限存取Server(192.168.2.1)
4.其餘行為皆禁止
Router-0(config)#access-list 102 permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
Router-0(config)#access-list 102 permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
Router-0(config)#access-list 102 permit ip host 192.168.1.253 host 192.168.2.1
Router-0(config)#int fa 0/1
Router-0(config-if)#ip access-group 102 out
Router-0(config-if)#do sh acc
Extended IP access list 102
    permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
    permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
    permit ip host 192.168.1.253 host 192.168.2.1

Controlling VTY(Telnet) Access 
使用IP標準ACL來控制VTY線路的訪問 , 設定步驟如下: 
1.創建個IP標準ACL來允許某些主機可以telnet 
2.使用access-class命令來應用ACL到VTY線路上 
實例如下: 
Router(config)#access-list 50 permit 172.16.10.3 
Router(config)#line vty 0 4 
Router(config-line)#access-class 50 in 
如上,進入VTY線路模式 , 應用ACL , 方向為進來 , 即in , 因為默認隱含的deny any , 所以上面的例子 , 只允許IP地址為172.16.10.3的主機telnet到router上。

Named Access Lists 
Router-0(config)#ip access-list extended test
Router-0(config-ext-nacl)#permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1 
Router-0(config-ext-nacl)#permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
Router-0(config-ext-nacl)#permit ip host 192.168.1.253 host 192.168.2.1 

Router-0(config-ext-nacl)#exit

Router-0(config)#int f0/0
Router-0(config-if)#ip access-group test in
Router-0(config-if)#do sh acc

Extended IP access list 102

    permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1 (4 match(es))
    permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www (10 match(es))
    permit ip host 192.168.1.253 host 192.168.2.1 (5 match(es))
Extended IP access list test
    permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
    permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
    permit ip host 192.168.1.253 host 192.168.2.1

Router-0#sh run
interface FastEthernet0/0
 ip address 192.168.1.254 255.255.255.0
 ip access-group test in
 duplex auto
 speed auto
!
!
access-list 102 permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
access-list 102 permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
access-list 102 permit ip host 192.168.1.253 host 192.168.2.1
ip access-list extended test
 permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
 permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
 permit ip host 192.168.1.253 host 192.168.2.1
!

Access List常用查詢指令
show access-lists(sh ip access-lists 也可)
Router-0#sh access-lists 
Extended IP access list 102
    permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1 (4 match(es))
    permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www (10 match(es))
    permit ip host 192.168.1.253 host 192.168.2.1 (5 match(es))

show access-lists +編號orWord(sh ip access-lists+編號orWord 也可)
Router-0#sh access-lists 102
Extended IP access list 102
    permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1 (4 match(es))
    permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www (10 match(es))
    permit ip host 192.168.1.253 host 192.168.2.1 (5 match(es))

show running-config
interface FastEthernet0/1
 ip address 192.168.2.254 255.255.255.0
 ip access-group 102 out
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
!
access-list 102 permit icmp 192.168.1.0 0.0.0.127 host 192.168.2.1
access-list 102 permit tcp 192.168.1.128 0.0.0.127 host 192.168.2.1 eq www
access-list 102 permit ip host 192.168.1.253 host 192.168.2.1


Subnet Mask & Wildcard Mask
Subnet Mask與Wildcard Mask的用途相同,只是表示的方法相反,在設定OSPF與ACL時都要用Wildcard Mask。
Subnet Mask 255.255.255.248   Wildcard Mask 0.0.0.7
Subnet Mask 255.255.255.128   Wildcard Mask 0.0.0.127
Subnet Mask 255.255.128.0   Wildcard Mask 0.0.127.255
Subnet Mask 255.192.0.0   Wildcard Mask 0.63.255.255

表172.30.16.0/24~172.30.31.0/24 ==>172.30.16.0 0.0.15.255

2012年3月9日 星期五

CCNA學習筆記(四)

Router Table come from?
1.自己產生。
2.手動建立。
3.就由鄰近的Router相互自動交換學習。

Static Route(靜態路由)
Router(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.2
(ip route Destination_prefix Destination _prefix_mask Forwarding_router's_address)

Router(config)#ip route 192.168.1.0 255.255.255.0 ?
  A.B.C.D            Forwarding router's address
  Ethernet             IEEE 802.3
  FastEthernet       FastEthernet IEEE 802.3
  GigabitEthernet  GigabitEthernet IEEE 802.3z
  Loopback          Loopback interface
  Null                   Null interface
  Serial                 Serial
  Vlan                  Catalyst Vlans


Ping無回應的狀況
1.Destination host unreachable.
Router不知道封包該往哪送,所以Router就直接回應給封包發送端說[無法到達目的地]。


PC>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.2.254: Destination host unreachable.
Reply from 192.168.2.254: Destination host unreachable.
Reply from 192.168.2.254: Destination host unreachable.
Reply from 192.168.2.254: Destination host unreachable.



2.Request timed out.
封包沒有在規定的時間內回傳(預設1sec),逾時,原因不清楚,可能是封包回不來,也可能是目的地不存在(故障),但可以確定的是本地端的Router已經把封包送出去了。

PC>ping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.


windows   tracert
UNIX       traceroute
CISCO     traceroute

Dynamic Route(動態路由)
RIP(Routing Information Protoccol)
RIP2(Routing Information Protoccol V2)
IGRP(Interior Gateway Routing Protocol)
EIGRP(Enhance Interior Gateway Routing Protocol)
OSPF(Open Shortest Path First)

網路級別(Classful、Classless)
有級別路由(Classful Routing):網路上所有主機及路由器介面使用相同的Subnet Mask。
RIP、IGRP。
無級別路由(Classless Routing):每個網段可以使用不同Subnet Mask。
RIP2、EIGRP、OSPF。

RIP

Router-0(config)#router ?
  bgp    Border Gateway Protocol (BGP)
  eigrp  Enhanced Interior Gateway Routing Protocol (EIGRP)
  ospf   Open Shortest Path First (OSPF)
  rip    Routing Information Protocol (RIP)
Router-0(config)#router rip
Router-0(config-router)#?
  auto-summary         Enter Address Family command mode(路徑總結)
  default-information  Control distribution of default information
  distance             Define an administrative distance
  exit                 Exit from routing protocol configuration mode
  network              Enable routing on an IP network
  no                   Negate a command or set its defaults
  passive-interface    Suppress routing updates on an interface
(限制RIP宣傳,不希望透過WAN送到外部網路)
  redistribute         Redistribute information from another routing protocol
  timers               Adjust routing timers
  version              Set routing protocol version
Router-0(config-router)#network 192.168.0.0
Router-0(config-router)#network 10.0.0.0


Router-1(config-router)#do sh ip rou
Codes: C - connected, S - static, I - IGRP, 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

     10.0.0.0/29 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/1
R    192.168.0.0/24 [120/1] via 10.1.1.1, 00:00:19, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/1] via 10.1.1.3, 00:00:24, FastEthernet0/1


Router-2(config)#router rip
Router-2(config-router)#passive-interface serial 0/1/0
Router-2(config-router)#do sh run


!
router rip
 passive-interface Serial0/1/0
 network 10.0.0.0
 network 192.168.2.0



RIP與RIP2比較表
RIP                                                          RIP2
有級別                                                     無級別
Broadcast                                                Multicast
不支援VLSM(可變長度Subnet Mask)         支援VLSM
不支援非連續網路                                    支援非連續網路
沒有認證                                                 可以使用MD5認證
不支援路徑總結                                       支援路徑總結

無級別網路(Classless)及路徑總結(Summary)
Summary,把原本分開的許多網段,合併成為一個大網段,減少Route Table資料量,及增加效率。
如:
192.168.0.0/24、192.168.1.0/24、192.168.2.0/24、192.168.2.0/24四個網段,原本Route Table要四筆,可合併為192.168.0.0/22,濃縮為一筆。

RIP2


Router-1(config)#router rip
Router-1(config-router)#version 2
Router-1(config-router)#no auto-summary(非連續網段,避免總結後造成Route錯誤)
Router-1(config-router)#network 192.168.1.0
Router-1(config-router)#network 10.0.0.0





Router-2#sh ip route 
Codes: C - connected, S - static, I - IGRP, 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

     10.0.0.0/29 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/1
C    192.168.0.0/24 is directly connected, FastEthernet0/0
     192.168.1.0/25 is subnetted, 2 subnets
R       192.168.1.0 [120/1] via 10.1.1.1, 00:00:26, FastEthernet0/1
R       192.168.1.128 [120/1] via 10.1.1.2, 00:00:16, FastEthernet0/1


Router-2#show ip protocol
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 3 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 2, receive 2
  Interface             Send  Recv  Triggered RIP  Key-chain
  FastEthernet0/1       2     2     
  FastEthernet0/0       2     2     
Automatic network summarization is not in effect
Maximum path: 4
Routing for Networks:
10.0.0.0
192.168.0.0
Passive Interface(s):
Routing Information Sources:
Gateway         Distance      Last Update
10.1.1.1             120      00:00:01
10.1.1.2             120      00:00:19
Distance: (default is 120)


Router-2#debug ip rip(如果是使用Telnet,必須再使用terminal monitor,才能看到訊息)
Router-2#no debug ip rip(先輸入,利用上下鍵,適時將debug及時停止)
RIP protocol debugging is off
Router-2#debug ip rip
RIP protocol debugging is on
RIP: received v2 update from 10.1.1.1 on FastEthernet0/1
      192.168.1.0/25 via 0.0.0.0 in 1 hops
RIP: received v2 update from 10.1.1.2 on FastEthernet0/1
      192.168.1.128/25 via 0.0.0.0 in 1 hops
RIP: sending  v2 update to 224.0.0.9 via FastEthernet0/1 (10.1.1.3) (Muticast)
RIP: build update entries
      192.168.0.0/24 via 0.0.0.0, metric 1, tag 0
RIP: sending  v2 update to 224.0.0.9 via FastEthernet0/0 (192.168.0.254)(Muticast)
RIP: build update entries
      10.1.1.0/29 via 0.0.0.0, metric 1, tag 0
      192.168.1.0/25 via 0.0.0.0, metric 2, tag 0
      192.168.1.128/25 via 0.0.0.0, metric 2, tag 0
Router-2#no debug ip rip


IGRP
是CISCO專屬。


EIGRP
是IGRP的加強版,也是CISCO專屬。

EIGRP與RIP協定的差異
RIP
使用中繼站(Hop)的數量來衡量最佳路徑(最多支援的Hop數量為15,Hop超過15的路徑視為斷線)。
每隔固定時間傳送路徑更新資訊。

EIGRP
採用複合式衡量指標來挑選最佳路徑,預設會考慮線路的頻寬與延遲做為參考指標,還可以參考可靠性、負載、與最大傳輸單位等指標。
當網路拓樸有異動時才傳更新資訊。
支援的Hop最多到255點,支援Classless網路,支援VLSM與Auto-summary。

EIGRP更新Route Table的方式,須符合以下條件才分享路徑資料
1.收到Hello或ACK封包。
2.AS(Autonomous System自治系統)號碼相同。
3.距離計算係數-K值相同(通常不會刻意修改)。
K值有5個,K1=1,K2=0,K3=1,K4=0,K5=0,K值不一樣不會形成鄰居。

EIGRP資料更新方式
當發現新鄰居時,傳送完整Route Table,之後只傳異動部分,無異動就不再傳資料,適合大型網路。

EIGRP

Router-2(config)#router eigrp 10(啟用EIGRP,並宣告AS=10)
Router-2(config-router)#network 192.168.0.0 255.255.255.0(另有一種Wildcard宣告方式)
Router-2(config-router)#network 10.1.1.0 255.255.255.248(另有一種Wildcard宣告方式)
Router-2(config-router)#no auto-summary


Router-2#sh ip route 
Codes: C - connected, S - static, I - IGRP, 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

     10.0.0.0/29 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/1
C    192.168.0.0/24 is directly connected, FastEthernet0/0
     192.168.1.0/25 is subnetted, 2 subnets
D       192.168.1.0 [90/30720] via 10.1.1.1, 00:11:24, FastEthernet0/1
D       192.168.1.128 [90/30720] via 10.1.1.2, 00:07:22, FastEthernet0/1


Router-2#sh ip route eigrp 
     192.168.1.0/25 is subnetted, 2 subnets
D       192.168.1.0 [90/30720] via 10.1.1.1, 00:11:34, FastEthernet0/1
D       192.168.1.128 [90/30720] via 10.1.1.2, 00:07:31, FastEthernet0/1


Router-2#sh ip eigrp neighbors 
IP-EIGRP neighbors for process 10
H   Address         Interface      Hold Uptime    SRTT   RTO   Q   Seq
                                   (sec)          (ms)        Cnt  Num
0   10.1.1.1        Fa0/1          12   00:13:05  40     1000  0   13
1   10.1.1.2        Fa0/1          11   00:09:03  40     1000  0   13


Router-2#sh ip eigrp topology 
IP-EIGRP Topology Table for AS 10

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - Reply status

P 192.168.0.0/24, 1 successors, FD is 28160
         via Connected, FastEthernet0/0
P 10.1.1.0/29, 1 successors, FD is 28160
         via Connected, FastEthernet0/1
P 192.168.1.0/25, 1 successors, FD is 30720
         via 10.1.1.1 (30720/28160), FastEthernet0/1
P 192.168.1.128/25, 1 successors, FD is 30720
         via 10.1.1.2 (30720/28160), FastEthernet0/1


Router-2#no debug eigrp packets 
EIGRP Packets debugging is off
Router-2#debug eigrp packets 
EIGRP Packets debugging is on
    (UPDATE, REQUEST, QUERY, REPLY, HELLO, ACK )
Router-2#
EIGRP: Received HELLO on FastEthernet0/1 nbr 10.1.1.1
  AS 10, Flags 0x0, Seq 14/0 idbQ 0/0

EIGRP: Received HELLO on FastEthernet0/1 nbr 10.1.1.2
  AS 10, Flags 0x0, Seq 14/0 idbQ 0/0

EIGRP: Sending HELLO on FastEthernet0/1
  AS 10, Flags 0x0, Seq 14/0 idbQ 0/0 iidbQ un/rely 0/0

EIGRP: Sending HELLO on FastEthernet0/0
  AS 10, Flags 0x0, Seq 14/0 idbQ 0/0 iidbQ un/rely 0/0

debug ip eigrp notification
顯示網路上發生的EIGRP異動與更新。

OSPF(Open Shortest Path first)
最短路徑優先,一種開放式的路由協定。

OSPF與EIGRP的差別
1.Hop Count上限:OSPF沒有上限
2.設定難易:OSPF設定較為複雜。

OSPF設計,以階層式架構來設計,將大型網路分割成數個較小的區域(Area)相互連結。
Area 0 ,稱之為BackBone Area(骨幹區域),其餘Area必須要和Area 0相連,如只規畫一個Area也可以,就是只有Area。

OSPF的設定基本項目有
1.啟用OSPF協定,並給予Process ID(1~65535)。
一台Router允許執行多個OSPF程序,用不同ID以區別,這個值只對本機有效,與其他Router無任何關係。
2.宣告網段範圍,並宣告屬於哪一個Area。


OSPF運作方式


1.Router ID(RID):用來識別Router的IP Address,一般為了穩定性,會在Router上介面設定虛擬LookBack IP Address(繞回位址)供辨識,當線路故障時,這個LookBack IP Address仍然可以持續運作。
以最高LookBack IP Address為RID,沒有設定時,以實體介面中數值最高的IP Address作為RID。
2.Hello封包:發送Hello封包自動發現鄰居,維護鄰居關係。
3.Nerighbor(鄰居):只有介面在相同網段,即可成為鄰居。
4.Adjacency(緊鄰關係):OSPF只與有良好關係(Adjacency)交換路由資料,能否建立Adjacency取決於Router的設定與網路的類型。
5.Neighborship Database(鄰居關係資料庫):所有OSPF鄰居清單,內容包含RID、Router狀態與其他細節。
6.Topology Database(拓樸資料庫):利用Topology Database中的資訊,計算出抵達每個網路的最短路徑。
7.LSA(Link State Advertisement連結狀態宣傳):LSA是一種OSPF資料封包,用來更新、維護Topology Database,OSPF只會與有緊鄰關係的Router交換LSA封包。
8.DR(Designated Router委任路由器):在所有可以形成緊鄰關係的Router中,挑選出一個代表,負責接受路由更新資訊,並廣播更新資訊給其餘的Router,確保所有資料庫同步,所有Router都會與DR建立緊鄰關係,而不是雜亂無章的隨意建立。
DR的產生,以優先權最高的RRouter取得,若相同,則以RID越高者優先取得DR。
9.BDR(Backup Designated Router備用委任路由器):產生方式與DR相同,第二優先權者為BDR,接收路由更新,但是不廣播更新資料,當DR故障時,取而代之。

DR與BDR的選舉
1.Router必須有介面屬於相同網段,並且有相同的Area ID。
2.相同的Hello Interval與Dead Interval(Hello與死亡時間間隔)。
3.相同的驗證碼(如有設定時)。

CISCO建議設定OSPF時,要使用LookBack Interface,可以提升OSPF運作的穩定性。
每台Router的LookBack IP Address必須屬於不同網段並且IP不能重複即可,因此LookBack Interface的Subnet Mask設定為255.255.255.255,就只要注意IP不要重複即可。


Router-2(config)#router ospf 1
Router-2(config-router)#network 192.168.0.0 255.255.255.0 area 0
Router-2(config-router)#network 10.1.1.0 255.255.255.248 area 0


Router-2#sh ip route 
Codes: C - connected, S - static, I - IGRP, 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

     10.0.0.0/29 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/1
C    192.168.0.0/24 is directly connected, FastEthernet0/0
     192.168.1.0/25 is subnetted, 2 subnets
O       192.168.1.0 [110/2] via 10.1.1.1, 00:02:45, FastEthernet0/1
O       192.168.1.128 [110/2] via 10.1.1.2, 00:01:19, FastEthernet0/1

Router-2#sh ip route ospf 
     192.168.1.0/25 is subnetted, 2 subnets
O       192.168.1.0 [110/2] via 10.1.1.1, 00:02:54, FastEthernet0/1
O       192.168.1.128 [110/2] via 10.1.1.2, 00:01:29, FastEthernet0/1


Router-2#sh ip ospf 
 Routing Process "ospf 1" with ID 192.168.0.254
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
 Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 External flood list length 0
    Area BACKBONE(0)
        Number of interfaces in this area is 2
        Area has no authentication
        SPF algorithm executed 6 times
        Area ranges are
        Number of LSA 4. Checksum Sum 0x03d25b
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0



Router-2#sh ip ospf neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.1.126     1   FULL/DR         00:00:31    10.1.1.1        FastEthernet0/1
192.168.1.254     1   FULL/DROTHER    00:00:30    10.1.1.2        FastEthernet0/1


Router-2#sh ip ospf database 
            OSPF Router with ID (192.168.0.254) (Process ID 1)

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.0.254   192.168.0.254   744         0x80000004 0x00feff 2
192.168.1.126   192.168.1.126   745         0x80000006 0x00feff 2
192.168.1.254   192.168.1.254   657         0x80000004 0x00feff 2

                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
10.1.1.1        192.168.1.126   658         0x80000003 0x00d55e


Router-2#sh ip ospf interface 
FastEthernet0/0 is up, line protocol is up
  Internet address is 192.168.0.254/24, Area 0
  Process ID 1, Router ID 192.168.0.254, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.0.254, Interface address 192.168.0.254
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:04
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 0, Adjacent neighbor count is 0
  Suppress hello for 0 neighbor(s)
FastEthernet0/1 is up, line protocol is up
  Internet address is 10.1.1.3/29, Area 0
  Process ID 1, Router ID 192.168.0.254, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 192.168.1.126, Interface address 10.1.1.1
  Backup Designated Router (ID) 192.168.0.254, Interface address 10.1.1.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:05
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 2, Adjacent neighbor count is 2
    Adjacent with neighbor 192.168.1.126  (Designated Router)
    Adjacent with neighbor 192.168.1.254
  Suppress hello for 0 neighbor(s)





















2012年3月7日 星期三

CCNA學習筆記(三)

STP (802.1D)
為了完成打斷迴圈的工作,在一群Switch中首先要選出Root Bridge,並且只能有一台Switch成為Root Bridge。
會比較兩個值,首先比較[Bridge ID](Priority ID+第一個VLAN ID),[值]越低則優先權越高。
Bridge ID相同時,在比較[MAC Address],一樣[值]越低的優先權越高。

STP埠之狀態
blocking凍結:中斷迴圈用。
listening聆聽:偵測沒有迴圈後準備傳送資料。
learning學習:產生MAC table。
forwarding轉送:傳送資料。
disable關閉:不參與任何運作。

收斂
當Switchs上所有的port狀態都變成Blockingforwarding狀態時,就叫達成收斂(Convergence)。

STP根據Cost(BW)來決定port為Blocking或Forwarding。
Giga port cost=4
100M port cost=19

PostFast
加速收斂時間,但使用這個指令就喪失STP的功能(無法打斷迴圈),一般可以用在末端的Switch,如果用在Core Switch或是還有串接其他Switch、Hub的設備,就要先確認線路有沒有迴圈。

RSTP(Rapid STP)快速STP (802.1W)
縮短收斂時間,只需要1-2秒
Switch#conf t
Switch(config)#spanning-tree mode rapid-pvst


Post Security交換埠的安全性(防非法MAC存取)
switch #configure terminal
switch (config)#interface fastEthernet 0/24  (多個Port可用range)
switch (config-if)#switchport mode access  (將Port運作模式改成Access Mode)
switch (config-if)#switchport port-security  (啟用Port Security機制)
switch (config-if)#switchport port-security maximum 1  (設定最大的MAC數量,上限為一筆)
switch (config-if)#switchport port-security mac-address sticky (自動記錄學到的Mac Address,不需手動輸入)
switch (config-if)#switchport port-security violation shutdown(預設,處理err-disabled,偵測到違反政策時,關閉該port)

switch(config-if)#switchport port-security violation restrict  (合法MAC接回就會通)

1.switchport port-security maximum 允許讓多少筆 Mac-Address通過
2.switchport port-security mac-address 允許哪些 Mac-Address過過這裡有兩個選項可選:一個是直接輸入讓它通過的Mac-Address,另一個是動態紀錄
3.switchport port-security violation 當不在允許列表的 Mac-Address出現時所 採取的動作
  a.protect 保護原有的 Mac-Address, 不允許其它 Mac-Address通過
  b.restrict 不允許通過, 且紀錄
  c.shutdown 讓該 Port Shutdown

當違規被Shutdown時
Switch#clear port-security all(清除Port-Security資料)
Switch#conf t
Switch(config)#int fa0/1(違規的介面)
Switch(config-if)#sh(關閉)
Switch(config-if)#no sh(啟用)


Access Port與Trunk Port
Switch Port有兩種運作模式,Access Mode、Trunk Mode。
設定為Access Mode時該Port只能指定給一個VLAN,也只能與許該VLAN的封包通過。
如是Trunk Port,則能允許任何的VLAN封包通過(除非你有設定管制)。

VLAN(IEEE 802.1Q)
Switch(config)#vlan 30(新增VLAN ID 30)
Switch(config-vlan)#vlan 40(新增VLAN ID 40)

Switch(config)#interface range fastEthernet 0/10-20
Switch(config-if-range)#switchport access vlan 50(新增VLAN ID 50,並把ports fa0/10-20加入)
% Access VLAN does not exist. Creating vlan 50


VTP-Trans1#vlan database 
% Warning: It is recommended to configure VLAN from config mode,
  as VLAN database mode is being deprecated. Please consult user
  documentation for configuring VTP/VLAN in config mode.


VTP-Trans1(vlan)#?
VLAN database editing buffer manipulation commands:
  exit  Apply changes, bump revision number, and exit mode
  no    Negate a command or set its defaults
  vlan  Add, delete, or modify values associated with a single VLAN
  vtp   Perform VTP administrative functions.
VTP-Trans1(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
VTP-Trans1(vlan)#no vlan 10
Deleting VLAN 10...
VTP-Trans1(vlan)#vtp ?
  client       Set the device to client mode.
  domain       Set the name of the VTP administrative domain.
  password     Set the password for the VTP administrative domain.
  server       Set the device to server mode.
  transparent  Set the device to transparent mode.
  v2-mode      Set the administrative domain to V2 mode.

Trunk
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk 

Switch(config-if)#switchport mode dynamic ?

  auto       Set trunking mode dynamic negotiation parameter to AUTO

  desirable  Set trunking mode dynamic negotiation parameter to DESIRABLE
Switch(config-if)#switchport trunk allowed ?
  vlan  Set allowed VLANs when interface is in trunking mode

1.switchport mode access: 強制接口成為access接口,並且可以與對方主動進行協商,誘使對方成為access模式。
2.switchport mode dynamic desirable: 主動與對協商成為Trunk接口的可能性,如果鄰居接口模式為Trunk/desirable/auto之一,則接口將變成trunk接口工作。如果不能 形成trunk模式,則工作在access模式。
3.switchport mode dynamic auto: 只有鄰居交換機主動與自己協商時才會變成Trunk接口,所以它是一種被動模式,當鄰居接口為Trunkdesirable之一時,才會成為 Trunk。如果不能形成trunk模式,則工作在access模式。
4.switchport mode trunk: 強制接口成為Trunk接口,並且主動誘使對方成為Trunk模式,所以當鄰居交換機接口為trunk/desirable/auto時會成為Trunk接口。
5.switchport nonegotiate: 嚴格的說,這不算是種接口模式,它的作用只是阻止交換機接口發出Dynamic Trunking Protocol (DTP)封包

SW01  Fa0/1
SW02  Fa0/1
Trunk是否形成?
Trunk
Trunk
O

Dynamic desirable
O

Dynamic auto
O

Access
X
Dynamic desirable
Trunk
O

Dynamic desirable
O

Dynamic auto
O

Access
X
Dynamic auto
Trunk
O

Dynamic desirable
O

Dynamic auto
X

Access
X
Access
Trunk
X

Dynamic desirable
X

Dynamic auto
X

Access
X
Switch0#conf t
Switch0(config)#int g1/1
Switch0(config-if)#switchport mode trunk 

Router#conf t
Router(config)#int fa0/0
Router(config-if)#no sh
Router(config-if)#int fa0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.1.254 255.255.255.0
Router(config-subif)#int fa0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.2.254 255.255.255.0

vlan10的PC設定Gateway為192.168.1.254
vlan10的PC設定Gateway為192.168.2.254
如此VLAN10及VLAN20就可以互通

VTP(Vlan Trunking Protocol)(CISCO專屬)
VTP是一種讓Switch之間可以自動相互同步VLAN設定的通訊協定。
使用VTP需先宣告一VTP Domain,網域中最少要有一台Switch作為VTP Server,其餘的Switch則成為VTP Client。當需要異動Vlan時,只能在VTP Server上異動,結果會同步更新到所有VTP Client。

VTP運作模式
1.Server Mode:可以新增、移除、修改Vlan,並同步更新到所有網域內的VTP Client。
2.Client Mode:只能被動接受VTP Server的Vlan資料庫,同步更新到本身的資料庫,無法在Client Mode下新增、移除、修改Vlan。
3.Transparent Mode:不參與VTP Domain內Vlan資料庫同步更新,可以在Transparent Mode下新增、移除、修改Vlan,但其結果只會紀錄再本身的資料庫中
  在Transparent Mode下的Switch接收到VTP Server的更新資訊時,會直接轉送給其他的Switch。

VTP-Server#conf t
VTP-Server(config)#vtp ?
  domain    Set the name of the VTP administrative domain.
  mode      Configure VTP device mode
  password  Set the password for the VTP administrative domain
  version   Set the adminstrative domain to VTP version
VTP-Server(config)#vtp mode ?
  client       Set the device to client mode.
  server       Set the device to server mode.
  transparent  Set the device to transparent mode.
VTP-Server(config)#vtp mode server 

VTP-Server#show vtp ?
  counters  VTP statistics
  password  VTP password
  status    VTP domain status
VTP-Server#show vtp status 
VTP Version                     : 2
Configuration Revision          : 0
Maximum VLANs supported locally : 255
Number of existing VLANs        : 5
VTP Operating Mode              : Server
VTP Domain Name                 : ABC
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0xB7 0x9A 0x90 0xBA 0xA0 0xA6 0xB4 0xD4 
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
Local updater ID is 0.0.0.0 (no valid interface found)

將新的交換機增加到域中,一定要保證該交換機的修訂號已經為0(Configuration Revision : 0),不然如剛好為Server Mode就可能會發生災難。
VTP修訂號存儲在NVRAM中,交換機的電源開關不會改變這個設定值.可以使用下列方法:
1.將交換機的VTP模式變到Transparent Mode,然後再變回Server Mode。
2.將交換機的VTP Domain名稱修改為一個不存在的名稱,然後再回到原來的VTP Domain名稱。
3.使用erase startup-config 或 erase nvram命令,清除交換機的配置和VTP資訊.再次啟動。