使用機器
- PC:Windows11
 - スイッチ:Cisco Catalyst WS-C2960L-8TS-LL
 - PC接続方法:USB-RJ45コンソールケーブル(コンソール接続)
 
コンソール接続の手順
- 
Cisco公式のUSBドライバ(Cisco USB Console Driver)をインストールし、再起動。
- PCがUSBコンソールケーブルを仮想COMポートとして認識するようになる。
 
 - RJ45コンソールケーブルでPCとスイッチを接続する。
 - PCの「デバイスマネージャ」でシリアルポートの情報を確認。
 - TeraTermで接続。デバイスマネージャで確認したポートに接続する。
 
LAN経由でSSHできるようにする設定(SSH接続用)
Ciscoスイッチ設定コマンド
Switch>
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.0.43 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#
Nov  1 07:47:35.932: %LINK-3-UPDOWN: Interface Vlan1, changed state to up
Switch(config-if)#exit
Switch(config)#ip default-gateway 192.168.0.1
Switch(config)#ip domain-name example123.local
Switch(config)#crypto key generate rsa modulus 2048
The name for the keys will be: Switch.example123.local
% The key modulus size is 2048 bits
% Generating 2048 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 7 seconds)
Switch(config)#
Nov  1 08:05:52.213: %SSH-5-ENABLED: SSH 1.99 has been enabled
Switch(config)#username root privilege 15 secret XXXXXXXXXXX
Switch(config)#line vty 0 4
Switch(config-line)#transport input ssh
Switch(config-line)#login local
Switch(config-line)#end
Switch#
Nov  1 08:14:18.545: %SYS-5-CONFIG_I: Configured from console by console
Switch#write memory
Building configuration...
[OK]
Switch#show interfaces vlan 1
Vlan1 is up, line protocol is up
  Hardware is EtherSVI, address is [MACアドレス] (bia [MACアドレス])
  Internet address is 192.168.0.43/24
  MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive not supported
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input 00:00:01, output 00:13:20, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     0 packets input, 0 bytes, 0 no buffer
     Received 0 broadcasts (0 IP multicasts)
     0 runts, 0 giants, 0 throttles
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
     0 packets output, 0 bytes, 0 underruns
     0 output errors, 3 interface resets
     444 unknown protocol drops
     0 output buffer failures, 0 output buffers swapped out
Switch#
| コマンド | 役割 | 
|---|---|
| enable | 特権EXECモードに入る | 
| configure terminal (または conf t) | グローバルコンフィギュレーションモードに入る | 
| interface vlan 1 | VLANインターフェースを選択(Ciscoスイッチの初期設定で全ポートがVLAN 1に所属している。) | 
| ip address ... | SwitchにIPを割り当て | 
| no shutdown | インターフェースを有効化 | 
| exit | 一階層戻る | 
| ip default-gateway ... | デフォルトゲートウェイ設定 | 
| ip domain-name [ドメイン名] | ドメイン名を設定(SSH用RSA鍵生成に必要) | 
| crypto key generate rsa modulus 2048 | SSH用のRSA暗号鍵ペアを生成(2048ビット) | 
| username [ユーザ名] privilege 15 secret [パスワード] | ローカルユーザーアカウントを作成(最高権限レベル15) | 
| line vty 0 4 | 仮想端末ライン設定モードに入る(同時接続数5) | 
| transport input ssh | 接続プロトコルをSSHのみに制限(Telnet無効化) | 
| login local | ローカルデータベースで認証(ユーザー名+パスワード) | 
| end | 設定モード終了(すべての階層から一気に抜ける) | 
| write memory | 設定を保存(running-config → startup-config) | 
SSH接続確認
- スイッチとPCを同一LANにつなぐ。
 - PCのターミナルからスイッチへSSH
 
ssh root@192.168.0.43
→ パスワードを入力すれば、CLI操作が可能。