このページで解説している内容は、以下の YouTube 動画の解説で見ることができます。
スイッチのインターフェイスコンフィギュレーションモード
スイッチは、ルータと比べてたくさんのEthernetのポートを装備しています。
何も設定されていないスイッチの設定を「show running-config」コマンドで確認してみると次のように表示されます。インターフェイスが、「FastEthernet0/番号」になっていることが確認できます。
Switch#show runnning-config
●「show runnning-config」の出力
Switch#show running-config
Building configuration...
Current configuration : 1080 bytes
!
version 15.0
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
no ip address
shutdown
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
end
インターフェイスコンフィギュレーションモードに入るためには、
Switch(config)#interface FastEthernet 0/<番号>
番号:1~24
でポートを指定する必要があります。ルータのように「0」番は、ないので注意して下さい。
例えば、1番目のポートを設定したい場合は、次のように入力します。
Switch(config)#interface FastEthernet 0/1
Switch(config-if)#
省略コマンドで、
Switch(config)#int f0/1
と入力しても上の「interface FastEthernet 0/1」と同様の結果が得られます。
interface range コマンド
スイッチは、たくさんのインターフェイスを持っています。1つずつ、インターフェイスを設定していくのは面倒です。そんな時に便利なコマンドが「interface range」です。
「interface range」コマンドを使うと、複数のインターフェイスを、まとめて設定することができます。VLANの設定などを行っていく際に便利です。
構文は、以下の通りです。
Switch(config)#interface range <interface-type><slot>/<port>-<port>
Switch(config-if-range)#
使用例を2つ程、紹介します。
例1)interface range f0/1-8
連続したインターフェイスを、まとめて設定する時のは、の範囲を「-」で指定します。
例2)interface range f0/1-8,f0/16-24,g0/1
連続しない複数のインターフェイスを、まとめて設定するためには、「,」で区切って指定します。
「,」で区切った後の指定は、再度、<interface-type>から指定していきます。