マルチレイヤスイッチ(以下:L3SW)において、VLANとルーテッドポートの設定および
通信をいろいろと確認してみます(結果わかってますけど)
ルーテッドポート
スイッチポートと違いルーティングができるポート
L3SWのデフォルト設定となる
VLANインターフェース
SVI(Switch Virtual Interface)とも呼ばれ、スイッチポートでもルーティングできるようになる
設定的にはスイッチポートにアドレスを付与する
L2SWを死活監視したいときもこの機能を使う
ホスト名変更
Switch>en
Switch#
↑特権モードにはいる
Switch#conf t
↑設定はコンフィグレーションモードにはいる
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname SW-1
SW-1(config)#do write memory
↑モードがちがうので、「write memory」使えないので
「do」コマンドでモード関係なくコマンドを使用する
Building configuration…
[OK]
インターフェース設定(ルーテッドポート)
Switch(config)#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa0/1
^
% Invalid input detected at ‘^’ marker.
Switch(config)#do sh int status
↑機器によってポート構成が違うので
事前に”sh int status”などで確認するとよい
Port Name Status Vlan Duplex Speed Type
Fa1/0/1 notconnect 1 auto auto 10/100BaseTX
Fa1/0/2 notconnect 1 auto auto 10/100BaseTX
Fa1/0/3 notconnect 1 auto auto 10/100BaseTX
Fa1/0/4 notconnect 1 auto auto 10/100BaseTX
Fa1/0/5 notconnect 1 auto auto 10/100BaseTX
Fa1/0/6 notconnect 1 auto auto 10/100BaseTX
~省略~
SW-1(config)#sh int fa1/0/1
SW-1(config-if)#
SW-1(config-if)#no switchport
↑スイッチポートのままだとアドレスをふれない
SW-1(config-if)#ip address 192.168.11.101 255.2 255.255.255.0
SW-1(config-if)#no shutdown
↑インターフェースの有効化
SW-1(config-if)#int fa1/0/2
SW-1(config-if)#no switchport
SW-1(config-if)#ip address 192.168.11.102. 255.255.255.0
192.168.11.0 overlaps with FastEthernet1/0/1
↑要はfe1/0/1のセグメントとかぶってるってこと
SW-1(config-if)#no shutdown
VLAN作成(VLAN10 を fa1/0/3に割り当て)
SW-1(config-if)#interface fa1/0/3
SW-1(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
↑VLAN10が存在しないから、自動で作られる
00:17:01: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to down
SW-1(config-if)#switchport mode access
SW-1(config-if)#no shutdown
VLAN作成(VLAN10 を fa1/0/4に割り当て)
SW-1(config-if)#int fa1/0/4
SW-1(config-if)#switchport mode access
SW-1(config-if)#switchport access vlan 10
SW-1(config-if)#no shutdown
SW-1(config-if)#do sh run
↑「do」コマンドでモード関係なしに!
interface FastEthernet1/0/1
no switchport
ip address 192.168.11.101 255.255.255.0
!
interface FastEthernet1/0/2
no switchport
ip address 192.168.10.102 255.255.255.0
!
interface Vlan1
no ip address
!
interface Vlan10
no ip address
!
ip classless
ip http server
!
VLAN作成(VLAN20、30を作ってインターフェースに割り当て)
SW-1(config)#interface vlan 20
SW-1(config-if)#
00:19:39: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to down
SW-1(config)#int vlan 30
SW-1(config-if)#
00:22:02: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan30, changed state to down
SW-1(config)#int fa1/0/5
SW-1(config-if)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20
SW-1(config-if)#switchport mode access
SW-1(config-if)#int fa1/0/6
SW-1(config-if)#switchport access vlan 30
% Access VLAN does not exist. Creating vlan 30
SW-1(config-if)#switchport mode access
SW-1(config-if)#end
SW-1#wr me
Building configuration…
[OK]
SW-1#sh run
~抜粋~
interface FastEthernet1/0/3
switchport access vlan 10
switchport mode access
!
interface FastEthernet1/0/4
switchport access vlan 10
switchport mode access
!
interface FastEthernet1/0/5
switchport access vlan 20
switchport mode access
!
interface FastEthernet1/0/6
switchport access vlan 30
switchport mode access
!
interface Vlan1
no ip address
!
interface Vlan10
no ip address
!
interface Vlan20
no ip address
!
interface Vlan30
no ip address
!
デフォルトルート(ゲートウェイ)の設定
デフォルトルート設定
ip route 0.0.0.0 0.0.0.0 [ネクストホップアドレス/出力インターフェイス]
デフォルトゲートウェイ設定
ip default-gateway [IPアドレス]
デフォルトルートは その機器でIPルーティングを有効にした時(#ip routing)に使用し
デフォルトゲートウェイはIPルーティングを無効にした時に使用します。
L2SWなども、別NW向けの通信が発生する場合(運用・監視など)デフォルトゲートウェイの設定をする
ルータやL3SWなども、ホスト代わりに使いたいときなどにも有用する
SW-1(config)#ip route 0.0.0.0 0.0.0.0 192.168.11.1
SW-1#sh ip route
Default gateway is not set
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
SW-1(config)#ip routing
↑IPルーティングを無効にするには、グローバルコンフィグレーションモードでno ip routingコマンドを実行する
通常はデフォルトでONになる
SW-1(config)#ip default-gateway 192.168.11.1
SW-1#sh ip route
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
SW-1#write memory
Building configuration…
[OK]
SW-1#sh run
~抜粋~
ip default-gateway 192.168.11.1
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.11.1
ip http server
~抜粋~
SW-1(config)#ip route 0.0.0.0 0.0.0.0 192.168.11.1 permanent
↑宛先ルートへの出力インターフェースがダウンした場合でも、設定したスタティックルートのエントリーが消えてしまうので”permanent ”オプションつける
SW-1#sh ip route
Gateway of last resort is not set
↑でも、こちらの結果で消えている
これは、はじめっから、リンクダウンしてるから?
結線すると出てくる
SW-1# sh ip route
C 192.168.11.0/24 is directly connected, FastEthernet1/0/1
S* 0.0.0.0/0 [1/0] via 192.168.11.1
■no ip domain-lookup
SW-1#con ft
Translating “ft”…domain server (255.255.255.255)
% Unknown command or computer name, or unable to find computer address
↑すぐにといあわせちゃう(Ctrl+Shift+6 でキャンセル)
SW-1#conf
SW-1(config)#no ip domain-lookup
↑DNSサーバ機能を無効
■Portfast
SW-1(config)#int range fa1/0/1 – 2
↑インターフェースを編集する
rangeコマンドの設定例:
#interface range FastEthernet 0/1 – 9
#interface range FastEthernet 0/3 , FastEthernet 0/5 , FastEthernet 0/7
SW-1(config-if-range)#spanning-tree portfast
Command rejected: Fa1/0/1 is a routed port.
Command rejected: Fa1/0/2 is a routed port.
スイッチポートはデフォルトでリンクアップ50秒は時間がかかりすぎなので
portfast設定しようとおもいます
ルーテッドポートは当然ですがportfastはできません
SW-1(config)#int range fa1/0/3 – 6
SW-1(config-if-range)#spanning-tree portfast
↑これで、ケーブル抜き差ししてもリンクアップ時間短縮
<<通信試験>>
ルーテッドポート、VLAN、VLANインターフェースそれぞれの組み合わせで通信できるか
【環境】
<PC-A> — <L3SW> — <PC-B>
ping対象:PC-A ⇔ PC-B
双方向でping確認(クライアントのFWで予期せぬ結果になる為)
【所属VLAN】
Fa1/0/1 routed
Fa1/0/2 routed
Fa1/0/3 VLAN10
Fa1/0/4 VLAN10
Fa1/0/5 VLAN20
Fa1/0/6 VLAN30
【通信試験結果】
Fa1/0/1 ⇔ Fa1/0/2 OK
Fa1/0/1 ⇔ Fa1/0/3 NG
Fa1/0/1 ⇔ Fa1/0/3(Fa1/0/3 VLANインターフェースにする) OK
Fa1/0/3 ⇔ Fa1/0/4 OK
Fa1/0/5 ⇔ Fa1/0/6(片方だけVLANインターフェースにする) NG
ルーテッドポートは「内部ルータと直接つながっているポート」で
そのインターフェースに振るアドレスが直接ルーティングテーブルに載ります
VLANに所属しているインターフェースで別のネットワークおよび別のVLANにアクセスする場合は
VLANにアドレスを振る必要があり(VLANインターフェース)
これにより、VLANに所属するアドレスがルーティングテーブルに載ります
C 192.168.11.0/24 is directly connected, Vlan20
C 192.168.12.0/24 is directly connected, Vlan30
ルーティングテーブルに記載されたもの同士間の通信は当然ながら成功します
また、同じVLAN番号間の通信はL2レベルとなるので、PC-A,PC-Bのアドレスは同セグメントになります