【保存版】現役ネットワークエンジニアの最速Catalyst設定テンプレート(穴埋め式)

現役ネットワークエンジニアの僕がCatalystセットアップ時に使用するテンプレートを公開します。いわゆる飯のタネってやつですが、惜しげも無くアッサリと公開してしまいます。あーあ。。穴埋め式にしていますので、必要な部分だけご自身の環境にあったものに変えてお使い頂ければあっという間に”動く”Catalystが出来上がると思います〜(ほんまかいな)

はじめになまえありき

何は無くともホスト名は必要でしょうと言うことでホスト名の設定をしましょう。

hostnameコマンド
Switch(config)#hostname [ホスト名]

記号の一部はホスト名に使用出来ないのでご注意を。。
hostnameコマンド(記号エラー表示)
Switch(config)#hostname @
% Hostname contains one or more illegal characters.

このサービスは止めておきましょ

DNS サービスは不要であれば止めておくことがオススメです。僕の場合、タイピングミスした際に名前解決されるとイラッとするので、いつも一番最初に止めちゃいます。タイプミスをしてプロンプトが返って来るまで、25秒くらいかかりました(実際に測ってみた!)。少なくとも構築時は入れておくことをオススメします!

no ip domain-lookupコマンド
Switch(config)#no ip domain-lookup

確認コマンドは「show ip dns view」コマンドを使用します。
show ip dns viewコマンド
Switch#show ip dns view
DNS View default parameters:
DNS Resolver settings:
Domain lookup is disabled
Default domain name:
Domain search list:
Domain name-servers:
255.255.255.255
DNS Server settings:
Forwarding of queries is enabled
Forwarder addresses:


続いては、CDPですね。これも要件に無ければ、セキュリティ的に止めておく方がオススメですね。特にインターネット側のインタフェースではオフにしておきましょう。ここでは、機器全体のCDP機能を無効化するコマンドを紹介します。
cdp runコマンド
Switch(config)#no cdp run
確認コマンドは「show cdp neighborsコマンド」です。
show cdp neighborsコマンド
Switch#show cdp neighbors
% CDP is not enabled

パスワードももちろん要りますよね

社内の検証で使うと言ってもパスワードの設定は必要ですね。telnet設定をする際も必要なので入れておきましょう。Cisco機器のパスワード設定方法は、2種類あります。パスワードが暗号化されるかされないかの違いですが、暗号化する「enable secretコマンド」を使用することがほとんどですね。

enable secretコマンド
Switch(config)#enable secret [パスワード]

enable secretコマンドではパスワード部分が暗号化されます。
enable secretコマンド使用時のshow running-config(抜粋)

Switch#show running-config
Building configuration…
!
enable secret 5 $1$CFVd$NbSPGMpaU8fYzc6uVf/Gc1
!

ちなみに、enable passwordコマンドの場合も見てみましょう。
(ご参考)enable passwordコマンド
Switch(config)#enable password [パスワード]

enable passwordコマンドだとパスワード部分が暗号化されませんので丸見え状態です。。。
(ご参考)enable passwordコマンド使用時のshow running-config(抜粋)

Switch#show running-config
Building configuration…
!
enable password cisco
!

お客様、ルーティングは如何ですか?

ルーティングをする場合は「ip routingコマンド」を有効にしておきましょう。入れ忘れることが多いコマンドなので、気を付けましょう。後輩が「スタティックルート設定したのに、ルーティング出来ません〜」って騒いでいたので、見てみるとこのコマンドが入っていなかっただけと言うことがありましたね。。最近ではL2スイッチでも使用出来るので、もしかしたら使うことがあるかもしれませんね。

ip routingコマンド
Switch(config)#ip routing
確認コマンドは「show ip routeコマンド」ですね。

show ip routeコマンド(ip routingコマンド有効時)
Switch#show ip route
Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area
N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2
E1 – OSPF external type 1, E2 – OSPF external type 2
i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2
ia – IS-IS inter area, * – candidate default, U – per-user static route
o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP
a – application route
+ – replicated route, % – next hop override, p – overrides from PfR

Gateway of last resort is not set

Switch#


ちなみに、ip routingコマンドが有効になっていない時はこんな出力です。
(参考)show ip routeコマンド(ip routingコマンド無効時)
Switch#show ip route
Default gateway is not set
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
Switch#

VLANは名前を付けると分かりやすいですよ

VLANは名前を付けておくと、コンフィグ見ただけでどのVLAN か分かるので便利です。

vlanコマンド&nameコマンド
(config)#vlan [VLAN番号]
(config-vlan)#name [VLAN名]

確認コマンドは「show vlanコマンド」です。
show vlanコマンド
Switch#show vlan
VLAN Name Status Ports
—-      ——————————– ——— ——————————-
1        default                         active
100    CISCO                          active
1002  fddi-default                  act/unsup
1003  token-ring-default         act/unsup
1004  fddinet-default             act/unsup
1005  trnet-default                 act/unsup
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
—- —– ———- —– —— —— ——– —- ——– —— ——
1 enet 100001 1500 – – – – – 0 0
100 enet 100100 1500 – – – – – 0 0
1002 fddi 101002 1500 – – – – – 0 0
1003 tr 101003 1500 – – – – – 0 0
1004 fdnet 101004 1500 – – – ieee – 0 0
1005 trnet 101005 1500 – – – ibm – 0 0
Primary Secondary Type Ports
——- ——— —————– ——————————————

リモート用(telnet)の設定はこちらです

telnetはline vtyにパスワードを設定すればOKです(機器パスワードは上記で設定しているので省略)。デフォルトのコンフィグでは「line vty 0 4」の「0,1,2,3,4」の5本分のline設定ですが、足りなくなることもあるので僕の場合は「line vty 0 15」などにして設定することが多いです。

line vtyコマンド&passwordコマンド
(config)#line vty 0 4
(config-line)#password [パスワード]

それでは、telnet出来るか実験してみましょう。
telnetコマンド実行時出力
Switch#telnet 192.168.100.1
Trying 192.168.100.1 … Open

User Access Verification

Password:
Switch>en
Password:
Switch#

時刻設定は大切

ログの出力を考えると機器の時刻が合っていることは重要です。タイムゾーンとNTPの設定を紹介します。日本に設置する機器であれば「JST」の設定を入れておきます。

clock timezoneコマンド
(config)#clock timezone JST 9

NTPサーバーの指定は、「ntp serverコマンド」を使用します。
ntp serverコマンド
(config)#ntp server 192.168.100.1

確認コマンドは「show ntp associationsコマンド」もしくは「show ntp statusコマンド」です。
show ntp associationsコマンド
(config)#ntp server 192.168.100.1

show ntp statusコマンド
(config)#ntp server 192.168.100.1

テンプレートはこちらです

–★テンプレートここから★–

service timestamps debug datetime localtime show-timezone
service timestamps log datetime localtime show-timezone
service password-encryption
service sequence-numbers
!
hostname [ホスト名]
!
ip routing
!
no ip domain lookup
!
vtp mode transparent
!
no spanning-tree vlan [VLAN番号]
!
vlan [VLAN番号]
name [VLAN名]
!
no cdp run
!
interface GigabitEthernet0/1
switchport mode access
switchport access vlan [VLAN番号]
!
interface GigabitEthernet0/2
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan [VLAN番号]
!
interface Vlan[VLAN番号]
ip address [IPアドレス] [サブネットマスク]
!
no ip http server
no ip http secure-server
!
line con 0
password [コンソールログインパスワード]
logging synchronous
login
exec prompt timestamp
line vty 0 15
password [telnetパスワード]
logging synchronous
login
exec prompt timestamp
!
ntp server [NTPサーバアドレス]!
–★テンプレートここまで★–

コメントを残す

メールアドレスが公開されることはありません。