カテゴリ:

使うと便利ですが、慣れないと設定が分かりづらいのがmenuコマンドです。ここではごく簡単な設定をして利用方法を確認します。

R1に設定を行います。まずmenuコマンドに続いて、設定するメニューの名前を指定します。ここではMYMENUとします。併せてメニューのタイトルを指定します。分かりづらいですが、行末に使った文字で最後に閉じます。

R1(config)#menu MYMENU title -
Enter TEXT message.  End with the character '-'.
This is my menu
-
R1(config)#

続けて実際に表示するメニューを作成します。今回は1番がshow ip route、2番がshow ip interface bried、3番がexitを設定してみます。

1番をまず設定します。textに続けて"1"を入力し、その後表示する文字列を指定します。

R1(config)#menu MYMENU text ?
  WORD  Menu item number or character

R1(config)#menu MYMENU text 1 ?
  LINE  Text for this menu item

R1(config)#menu MYMENU text 1 show ip route

次に実際に実行されるコマンドを指定します。

R1(config)#menu MYMENU command 1 ?
  LINE  Command for this menu item

R1(config)#menu MYMENU command 1 show ip route

この手順で2番と3番も設定します。

R1(config)#menu MYMENU text 2 show ip interface brief
R1(config)#menu MYMENU command 2 show ip interface brief
R1(config)#menu MYMENU text 3 finish this menu
R1(config)#menu MYMENU command 3 exit

設定されたメニューはTELNETでユーザciscoでログインした場合に実行される設定を行います。

R1(config)#username cisco secret cisco
R1(config)#username cisco autocommand menu MYMENU
R1(config)#line vty 0 4
R1(config-line)#login local

TELNETで接続するとメニューが表示されることが分かります。

R1(config-line)#do telnet 17.17.1.1
Trying 17.17.1.1 ... Open

User Access Verification

Username: cisco
Password:
This is my menu

    1          show ip route

    2          show ip interface brief

    3          finish this menu

この状態で"1"を押すと下記のように表示されます。

Codes: 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

Gateway of last resort is not set

     17.0.0.0/24 is subnetted, 2 subnets
C       17.17.1.0 is directly connected, Loopback0
D       17.17.2.0 [90/156160] via 12.12.12.2, 00:26:11, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/0
This is my menu

    1          show ip route

    2          show ip interface brief

    3          finish this menu

次に"2"を押すと下記のようになります。

Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            12.12.12.1      YES manual up                    up
FastEthernet0/1            unassigned      YES unset  administratively down down
Serial1/0                  unassigned      YES unset  administratively down down
Loopback0                  17.17.1.1       YES NVRAM  up                    up
This is my menu

    1          show ip route

    2          show ip interface brief

    3          finish this menu

最後に"3"で終了となります。

[Connection to 17.17.1.1 closed by foreign host]

上手く活用すれば初心者に管理を任せることも可能になるでしょう。