CCNA L2まとめ

■L2 コマンド

見る系
・Switch#show interfaces status
・Switch#show vlan
・Switch#show run
・Switch#show interfaces trunk
・Switch#show ip interface brief
・Switch#show vtp status
・Switch#show spanning-tree
・Switch#show cdp neighbors



設定系

Switch(config-if)#switchport trunk encapsulation { isl | dot1q }
Switch(config-if)#switchport mode trunk

Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10

Switch(config)#interface fastethernet 0/2
Switch(config-if)#spanning-tree portfast


RA(config)#int fa2/0.3
RA(config-subif)#encapsulation dot1Q 77
RA(config-subif)#ip address 100.7.10.10 255.255.255.0


■IP・MACの表示
⇒show arp / show interfaces

「show arp」はARPテーブル(ARPキャッシュ)を表示するコマンドです。IPアドレスMACアドレスの対応付けが分かります。

「show interfaces」はインターフェースの情報を表示するコマンドです。これは自身のインターフェースのIPアドレスMACアドレスの対応付けが分かります。



■インタフェースのサマリ(VLAN)情報または詳細情報を表示させる 重要!!
Switch#show interfaces status

Port Name Status Vlan Duplex Speed Type
Fa0/1 connected 1 a-half a-10 10/100BaseTX
Fa0/2 connected 2 a-full a-100 10/100BaseTX
Fa0/3 connected 3 a-full a-100 10/100BaseTX
Fa0/4 connected trunk a-full a-100 10/100BaseTX





■VLAN確認

Switch#show vlan
VLAN Name Status Ports
1 default active Fa0/1, Fa0/2, Fa0/4, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12
2 VLAN0002 active
10 Ping-t active Fa0/5
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup

※trunkポートは特定のVLANに所属していないため、show vlanには表示されない。







Switch#show run

    • 省略--

interface FastEthernet0/1
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
switchport access vlan 10
switchport mode access
!

Switch#show interfaces fastEthernet 0/5 switchport
Name: Fa0/5
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: Off
Access Mode VLAN: 10 (Ping-t)
Trunking Native Mode VLAN: 1 (default)


その他のコマンドについて見ていきます。
「show start」は、設定の保存(copy run start)をした時点での設定です。
まだ設定の保存を行っていなければ表示されませんし、前回設定の保存を行ってから現在までに、割り当てたVLANを変更しているかも知れません。

Switch#show start
startup-config is not present ・・・設定が保存されていない(startup-configが存在しない)



■トランクポートだけを表示するコマンドです。
※以下はFa0/3がトランクポートである場合

Switch#show interfaces trunk

Port Mode Encapsulation Status Native vlan
Fa0/3 desirable 802.1q trunking 1

Port Vlans allowed on trunk
Fa0/3 1-4094

Port Vlans allowed and active in management domain
Fa0/3 1-2,10

Port Vlans in spanning tree forwarding state and not pruned
Fa0/3 1-2,10



■ポートの状態を一覧表示
※ポートに割り当てられたVLANまでは表示されません。

Switch#show ip interface brief
Interface IP-Address OK? Method Status Protocol
Vlan1 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset down down
FastEthernet0/2 unassigned YES unset down down
FastEthernet0/3 unassigned YES unset up up
FastEthernet0/4 unassigned YES unset down down
FastEthernet0/5 unassigned YES unset up up


■VTPに関する情報を表示
※ポートに割り当てられたVLANは表示されません。

show vtp status

VTP Version : 2
Configuration Revision : 8
Maximum VLANs supported locally : 64
Number of existing VLANs : 7
VTP Operating Mode : Server
VTP Domain Name :
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0xE5 0x75 0xC6 0x84 0xAD 0x99 0xF4 0x07
Configuration last modified by 0.0.0.0 at 3-1-93 01:32:10
Local updater ID is 0.0.0.0 (no valid interface found)




■show spanning-treeコマンド


「Spanning tree enabled protocol ieee」と表示されていることから、IEEE802.1dプロトコルが実行されているのがわかります。
RSTPが実行されている場合この部分に「Spanning tree enabled protocol rstp」と表示されます。

「Root ID」にはルートブリッジの情報が、「Bridge ID」には自身のローカルブリッジの情報が表示されますが、
MACアドレスが異なるため、この自身がルートブリッジではないことがわかります。
「Interface」には「Fa0/17」の表示がないため、Fa0/17のポートが使用されていないことがわかります。




CatA#show spanning-tree

VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address 0007.ec07.5300
Cost 19
Port 11 (FastEthernet0/11)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000a.f468.c380
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
Fa0/5 Desg FWD 19 128.5 P2p
Fa0/11 Root FWD 19 128.11 P2p


RSTP(IEEE802.1w)の 場合もこの画面に表示される。



トランクポートのカプセル化タイプを指定するコマンド

Switch(config-if)#switchport trunk encapsulation { isl | dot1q }


■portfast、uplinkfast設定

Switch(config)#interface fastethernet 0/2
Switch(config-if)#spanning-tree portfast



■VLAN間ルーティング(ルーター側設定)
RA(config)#int fa2/0.3
RA(config-subif)#encapsulation dot1Q 77
RA(config-subif)#ip address 100.7.10.10 255.255.255.0


VLAN間ルーティングにはデフォルトGWが必要。(SW側)
※ip default-gateway デフォルトゲートウェイIPアドレス



■SWの初期化

ルータの初期化を行うには、startup-configを消去し、再起動
・スイッチの初期化を行うには、startup-configを消去。
・VLAN情報を保存してあるvlan.dat(VLANデータベース)を消去しなければなりません。
 VLANデータベースを消去するには、「delete flash:vlan.dat」コマンドを使用します。

⇒startup-configとvlan.datを消去し、再起動を行うと、スイッチの初期化が完了します。


■ブリッジプライオリティ
ブリッジプライオリティとは、ブリッジIDを構成する要素です。
ブリッジIDはブリッジプライオリティとMACアドレスから構成されており、
スパニングツリーにおいて、ルートブリッジの選出に使用される値です。

ブリッジプライオリティを変更することで、ルートブリッジを変更し、
その結果、ブロッキングポートや、通信に使用する経路を意図的に操作することができます。




■CDP neighbors
CatA#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
CatB Fas 0/5 138 S I WS-C3550-2Fas 0/8
CatC Fas 0/11 144 S I WS-C2950-1Fas 0/11


■VTP
CatA#show vtp status
VTP Version : 2
Configuration Revision : 0
Maximum VLANs supported locally : 1005
Number of existing VLANs : 8
VTP Operating Mode : Server
VTP Domain Name : Ping-t
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x61 0x7F 0x02 0xEC 0x3B 0x13 0x46 0xF2
Configuration last modified by 0.0.0.0 at 3-1-93 00:04:03




VTP機能 サーバ クライアント トランスペアレント
VLAN情報の保存(FLASH) ○ ○ ○
VLAN情報の保存(running-config) × × ○
VTPの送受信 ○ ○ ×
VTPの転送 ○ ○ ○