labunix's blog

labunixのラボUnix

L2モデルのCatalystでL2の基本動作を確認する

■L2モデルのCatalystでL2の基本動作を確認する

 Cisco 1812JでL2の基本動作の確認する
 http://labunix.hateblo.jp/entry/20140503/1399046426

S1>show version | include cisco
cisco WS-C2970G-24T-E (PowerPC405) processor (revision L0) with 118784K/12280K bytes of memory.

■どのCatalystシリーズがL2かL3かを調べたいなら、
 以下の画像が凄くシンプルでわかりやすい。

 Cisco Systems社製 スイッチ Catalystシリーズ
 http://fenics.fujitsu.com/products/cisco_sh/

■環境は前回同様。

$ tree 172*
172.16.0.0.0-172.31.255.255_255.240.0.0
├── 172.16.16.200
│   ├── 172.16.16.200
│   ├── 172.16.16.201
│   └── 172.16.16.202
└── 172.31.31.201
    ├── 172.31.31.200
    ├── 172.31.31.201
    └── 172.31.31.202

■vifにIP設定
 「ip routing」が使えないのがL2。

S1>enable 
Password: 
S1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#no ip routing
                  ^
% Invalid input detected at '^' marker.

S1(config)#interface vlan 1
S1(config-if)#ip address 172.31.31.200 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#end
S1#show ip interface brief | include up.*up
GigabitEthernet0/13    unassigned      YES unset  up                    up      
GigabitEthernet0/14    unassigned      YES unset  up                    up      

■L2である代わりに、1Gbpsで24ポート。VLAN系のコマンドが使いやすい。
 アクセス層の役割としては十分。

S1#show vlan brief | exclude 100[2-5]

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/1, Gi0/2, Gi0/3, Gi0/4
                                                Gi0/5, Gi0/6, Gi0/7, Gi0/8
                                                Gi0/9, Gi0/10, Gi0/11, Gi0/12
                                                Gi0/13, Gi0/14, Gi0/15, Gi0/16
                                                Gi0/17, Gi0/18, Gi0/19, Gi0/20
                                                Gi0/21, Gi0/22, Gi0/23, Gi0/24
S1#show vtp status
VTP Version                     : 2
Configuration Revision          : 0
Maximum VLANs supported locally : 1005
Number of existing VLANs        : 5
VTP Operating Mode              : Transparent
VTP Domain Name                 : 
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x57 0xCD 0x40 0x65 0x63 0x59 0x47 0xBD 
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00

■ping check from debian

$ for n in `seq 200 202`;do \
    env LANG=C /sbin/ifconfig | grep 172.31.31.${n} || \
      traceroute -n 172.31.31.${n} | grep ms; \
  done
 1  172.31.31.200  0.380 ms * *
 1  172.31.31.201  0.135 ms  0.106 ms  0.081 ms
          inet addr:172.31.31.202  Bcast:172.31.31.255  Mask:255.255.255.0

$ for n in `seq 200 202`;do \
    env LANG=C /sbin/ifconfig | grep 172.31.31.${n} || \
      traceroute -n 172.31.31.${n} | grep ms; \
  done
 6  * 172.31.31.200  0.391 ms *
          inet addr:172.31.31.201  Bcast:172.31.31.255  Mask:255.255.255.0
 1  172.31.31.202  0.185 ms  0.186 ms  0.167 ms

S1#show ip arp 
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  172.31.31.200           -   00xx.xxxx.xxxx  ARPA   Vlan1
Internet  172.31.31.201           1   00yy.yyyy.yyyy  ARPA   Vlan1
Internet  172.31.31.202           1   00zz.zzzz.zzzz  ARPA   Vlan1
Internet  172.16.16.201           3   00ww.wwww.wwww  ARPA   Vlan1

■デフォルトGWを設定
 ルーティング確認用の「show ip route」が使えないので、コンフィグから直接確認。

S1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#ip default-gateway 172.31.31.201
S1(config)#end
S1#show running-config | include default
ip default-gateway 172.31.31.201
S1#show interfaces vlan1 | include Internet
  Internet address is 172.31.31.200/24

■ルーティングチェック from debian

$ env LANG=C /sbin/ifconfig eth1 | grep "inet "
          inet addr:172.16.16.200  Bcast:172.16.16.255  Mask:255.255.255.0
$ traceroute -n 172.31.31.200
traceroute to 172.31.31.200 (172.31.31.200), 30 hops max, 60 byte packets
 1  172.16.16.201  0.336 ms  0.260 ms  0.224 ms
 2  172.31.31.200  0.585 ms * *

■ルーティングチェック from WS-C2970G

S1#traceroute 172.16.16.200

Type escape sequence to abort.
Tracing the route to 172.16.16.200

  1 172.31.31.201 0 msec 0 msec 0 msec
  2 172.16.16.200 0 msec 0 msec 0 msec
S1#

■VLANコマンドはパッと見るだけでも、ルータモデルよりCatalystの方が便利そう。