Cisco 1812-Jの設定



●設定の初期化及びパスワードの復旧方法

 オークション等で入手したルータでパスワードが設定されており、どうしようも無いときにこの方法で初期化することにより利用できるようになります。

 パスワードの復旧

 Cisco ルータの工場出荷時のデフォルト設定へのリセット

 ルータを起動中にブレーク信号「ctrl+Break」キーを押し、ROMモニタモードへ移行します。
 ※Teratermの場合は「コントロール」→「ブレーク送信」をクリック
rommon 1 >
rommon 1 >confreg 0x2142
rommon 2 >reset
 これで起動時にstartup-configを読み込まない設定となり、初期状態で起動するようになります。起動したらstartup-configを移植し、パスワードを変更します。
router#copy startup run
Destination filename [running-config]?
1191 bytes copied in 1.233 secs (966 bytes/sec)
test#conf t
Enter configuration commands, one per line. End with CNTL/Z.
test(config)#enable password cisco
 ↑ enable secretが設定されている場合はenable secretで上書きされる
test(config)#line con 0 ← コンソールパスワードの設定
test(config-line)#password cisco ← パスワードを「cisco」にする
test(config-line)#login
test(config)#config-register 0x2102
test(config)#^Z
test#wr
*Mar 29 14:32:45.172: %SYS-5-CONFIG_I: Configured from console by consoleme
Building configuration...
[OK]
test#
config-register 0x2102を設定しないとリロードした場合に再度
Would you like to enter the initial configuration dialog? [yes/no]:
と表示され、起動時にstartup-configを読み込まないので必ず設定を行います。

 現在の情報を収集する

 設定情報を削除する前に、各種情報を収集します。
test#show tech-support
 障害時にサポートに提出するログが出力されます。

 設定の初期化

 設定を初期化するには下記のようにします。
test#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
test#reload
System configuration has been modified. Save? [yes/no]: no
 ↑ 再起動前に設定変更し、コンフィグを保存していない場合に表示される
Proceed with reload? [confirm]
*Mar 29 15:01:12.239: %SYS-5-RELOAD: Reload requested by console. /
    Reload Reason: Reload Command.

●スイッチポートへのIPアドレス割り当て

 IPアドレスを割り当てようとすると、
Router(config)#int f5
Router(config-if)#ip address 192.168.0.1 255.255.255.0
% IP addresses may not be configured on L2 links.
 スイッチポーはなのでIPアドレスを割り当てられないと怒られてしまう。
Router(config-if)#no switchport
% Incomplete command.
 ルーテットポートにもできません。
Router(config-if)#switchport portsecurity
   ^
% Invalid input detected at '^' marker.
 セキュリティもかけられません。
 IPアドレスを割り当てるにはVLANを設定します。
Router#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Router(vlan)#vlan 2
VLAN 2 added:
Name: VLAN2
hrj-Router(vlan)#vlan 3
VLAN 3 added:
Name: VLAN3
hrj-Router(vlan)#vlan 4
VLAN 4 added:
Name: VLAN4
hrj-Router(vlan)#vlan 5
VLAN 5 added:
Name: VLAN5
hrj-Router(vlan)#vlan 6
VLAN 6 added:
Name: VLAN6
hrj-Router(vlan)#vlan 7
VLAN 7 added:
Name: VLAN7
hrj-Router(vlan)#vlan 8
VLAN 8 added:
Name: VLAN8
hrj-Router(vlan)#vlan 9
Vlan can not be added. Maximum number of 8 vlan(s) in the database.
 VLANは8つまでしか設定できません。
Router(config)#int vlan 2
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
 VLANにIPを設定すれば、まあルーテッドポートのように使用できます。
Router(config-if)#switchport mode trunk
 トランクポートとして設定しても....しかしFECが組めません。
Router(config-if)#chanel-group 1 mode on
^
% Invalid input detected at '^' marker.

●ルータの起動直後

 ルータの起動直後
を参照してください。
Would you like to enter the initial configuration dialog? [yes/no]:
で「yes」入力すると、setupモードに移行します。

●setupモード

 setupモード
を参照してください。しかし、このsetupモードでは詳細な設定はできないので、Ciscoの設定コマンドに早く慣れるようにしてください。
 以下、コマンドで設定することとします。
 再起動後、sh confで確認しコンフィグがないことを確認します。
Router#sh conf
startup-config is not present
Router#

 ドメインの設定

 ドメイン名を設定しておきます。SSHを使う場合は必須です。
Router(config)#ip domain name kumo.jp

 タイムゾーンの設定

 時刻をJSTで表示するようにします。
Router(config)#clock timezone JST 9

 ログ表示の設定(その1)

 ログの時刻表示をローカル時間で表示させます。
Router(config)#service timestamps debug datetime msec localtime
Router(config)#service timestamps log datetime msec localtime

 ログ表示の設定(その2)

 デフォルトのままではログは表示されません。以下の方法により表示されるようにします。
Router(config)#logging buffered <4096-2147483647:バッファサイズ(bytes)>

●便利なコマンド

--More-- を非表示にする
Router# terminal length 0
デフォルトは24。ログアウトするとデフォルトに戻ります。

telnet 接続でコンソール接続と同様にログをリアルタイムで表示
Router# terminal monitor 
ログを非表示にする
Router# no logging console
●showコマンド実行中に文字列検索

 show コマンドを実行中に --More-- が表示されている状態で、「/」を入力した後に、検索したい文字列を入力しリターンキーを押すと、その文字列が含まれている箇所までジャンプします。
 実際に試してみます。
 『show run』を実行します。
Current configuration : 4059 bytes
!
! Last configuration change at 16:55:49 JST Sat Feb 4 2012
! NVRAM config last updated at 16:55:52 JST Sat Feb 4 2012
! NVRAM config last updated at 16:55:52 JST Sat Feb 4 2012
version 15.1
service timestamps debug datetime msec localtime
service timestamps log datetime msec localtime
service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
!
!
logging buffered 32678
enable secret 5 $1$qObM$MQ11Gjf8fadfUEYGYhfyaf6FVeec0
!
no aaa new-model
!
clock timezone JST 9 0
crypto pki token default removal timeout 0
!
!
dot11 syslog
ip source-route
!
!
ip dhcp excluded-address 192.168.0.1 192.168.0.100
ip dhcp excluded-address 192.168.0.241 192.168.0.254
!
ip dhcp pool local
 network 192.168.0.0 255.255.255.0
 --More--
 ここで『/pppoe』と入力。
filtering...
 pppoe enable group global
 pppoe-client dial-pool-number 1
!
interface FastEthernet1
 no ip address
 duplex auto
 speed auto
 のように『pppoe』を含む行までジャンプします。

●設定中(コンフィグレーションモード)に showコマンドを確認したいとき

 設定中(コンフィグレーションモード)にshow runコマンドで設定を確認したいときがあると思います。コンフィグレーションモードで『show run』を実行してもエラーになってしまします。

 しかし、いちいちコンフィグレーションモードを戻るのも面倒です。そんな時に便利なコマンドが『do』コマンドです。実際に実行したいコマンドの前に、「do」を付けて実行します。『show run』コマンドを実行したい場合は。
Router(config)# do show run
 これでコンフィグレーションモード中でも、『show run』結果を確認することができます。show run以外のshowコマンドはもちろん、Pingコマンドなども使用可能です。
Router(config)# do ping 192.168.0.1

●パスワードの変更方法

 下記URLを参照してください。
 パスワードを設定する

●基本的な設定

 下記URLを参照してください。
 基本的なパラメータの設定

●NTPの設定

 下記URLを参照してください。
 NTPアソシエーションの設定

 時刻の同期確認方法は下記のとおりです。
# show ntp status
Clock is synchronized, stratum 3, reference is ***.***.***.***
 Clock is synchronizedと表示されれば同期されています。

●DNSの設定

 下記URLを参照してください。
 DNSの概要

●PPPoEの設定

 いろいろなページを参照して下記のように設定しました。
 参照したページ
 初期設定 Cisco1812Jを自宅で利用PPPoE編①
 初期設定 Cisco1812Jを自宅で利用PPPoE編②
 インターネット接続 - PPPoE(端末型払い出し)ルータの設定例:
 NATによるPPPoEの設定
interface FastEthernet0
 no ip address
 duplex auto
 speed auto
 pppoe enable group global ← IOSバージョンによりこのように表示される
 pppoe-client dial-pool-number 1
  ↑ このインターフェースではカプセル化をPPPへ変更できない。
    PPPを使用できるようDialerインタフェースとのマッピング用に
    「pppoe-client dial-pool-number」コマンドを使用。
    dialer pool 1とマッピング
interface FastEthernet8
 switchport access vlan 3
 no ip address
!
interface FastEthernet9
 switchport access vlan 3
 no ip address
interface Vlan3
 ip address 192.168.100.254 255.255.255.0
 ip nat inside ← 内部プライベートネットワークを指定
 ip virtual-reassembly in ← NATを設定すると自動的に付加される
 ip tcp adjust-mss 1414 ← ユーザデータ長は1414バイト
!
interface Dialer0
 ip address negotiated ← PPPoEでIPアドレスを自動取得
 ip mtu 1454 ← IPデータグラムの最大値
 ip nat outside ← 外部グローバルネットワークを指定
 ip virtual-reassembly in
 encapsulation ppp ← このインターフェースでPPP化
 dialer pool 1 ← プロファイル定義を「1」に設定
 dialer-group 1 ← 「dialer-list 1」と「dialer-group 1」の「1」がマッピング。
 ppp authentication chap callin
  ↑ CHAP認証を利用。「callin」設定により、ISPによる片方向のユーザ認証のみ
 ppp chap hostname ************** ← 接続用ユーザ名
 ppp chap password 7 ************** ← 接続用パスワード
ip nat inside source list 1 interface Dialer0 overload
  ↑ WAN側の出口「Dialer 0」を利用し、PAT変換
ip nat inside source static tcp 192.168.0.100 22 interface Dialer0 22
ip nat inside source static tcp 192.168.0.100 25 interface Dialer0 25
ip nat inside source static tcp 192.168.0.100 53 interface Dialer0 53
ip nat inside source static udp 192.168.0.100 53 interface Dialer0 53
ip nat inside source static tcp 192.168.0.100 80 interface Dialer0 80
ip nat inside source static tcp 192.168.0.100 110 interface Dialer0 110
ip nat inside source static tcp 192.168.0.100 123 interface Dialer0 123
ip nat inside source static udp 192.168.0.100 123 interface Dialer0 123
ip nat inside source static tcp 192.168.0.100 143 interface Dialer0 143
ip nat inside source static tcp 192.168.0.100 443 interface Dialer0 443
ip nat inside source static tcp 192.168.0.100 993 interface Dialer0 993
ip nat inside source static tcp 192.168.0.100 995 interface Dialer0 995
  ↑ ip nat inside source staticで始まる行はサーバ公開のための設定
ip route 0.0.0.0 0.0.0.0 Dialer0 ← デフォルトルートの設定
!
access-list 1 permit 192.168.100.0 0.0.0.255 ← アクセスリストの設定
dialer-list 1 protocol ip permit
 これでshow interface Dialer0をすれば、割り当てられているIPアドレスを確認することができます。
 デバッグ方法については、下記を参照してください。
 トラブルシューティング:PPP(CHAP または PAP)認証
 debug ppp negotiation の出力について

●ファイアーウォールの設定(PPPoE)

・ACLによるIPスプーフィング対策
Router_A(config)#access-list 100 deny ip 0.0.0.0 0.255.255.255 any
Router_A(config)#access-list 100 deny ip 10.0.0.0 0.255.255.255 any
Router_A(config)#access-list 100 deny ip 127.0.0.0 0.255.255.255 any
Router_A(config)#access-list 100 deny ip 172.16.0.0 0.15.255.255 any
Router_A(config)#access-list 100 deny ip 192.168.0.0 0.0.0.255 any
Router_A(config)#access-list 100 deny ip 224.0.0.0 15.255.255.255 any
Router_A(config)#access-list 100 deny ip 240.0.0.0 15.255.255.255 any
・ACLによるNETBIOS・Windows共有サービスのブロック
 NETBIOS(ポート137〜139)、Windows共有サービス(SMB:ポート445)、TELNETを制限します。
Router_A(config)#access-list 100 deny tcp any any range 137 139
Router_A(config)#access-list 100 deny tcp any range 137 139 any
Router_A(config)#access-list 100 deny udp any any range netbios-ns netbios-ss
Router_A(config)#access-list 100 deny udp any range netbios-ns netbios-ss any
Router_A(config)#access-list 100 deny tcp any any eq 445
Router_A(config)#access-list 100 deny tcp any eq 445 any
Router_A(config)#access-list 100 deny udp any any eq 445
Router_A(config)#access-list 100 deny udp any eq 445 any
Router_A(config)#access-list 100 deny tcp any any eq telnet
Router_A(config)#access-list 100 permit ip any any

●ユーザ名とパスワードの設定ミス

 ユーザ名とパスワードの設定ミスがある場合、以下のメッセージが多発しますが、ppp authentication chapの後のコマンドである callin というパラメータが抜けていても、同様に以下のログメッセージが多発します。
 ※ ppp authentication chapコマンドのcallinパラメータがあることでユーザ認証は片方向だけとなり、ISPによるユーザ認証だけとなります。
*May 20 20:53:18.524: %DIALER-6-BIND: Interface Vi2 bound to profile Di0
*May 20 20:53:18.528: %LINK-3-UPDOWN: Interface Virtual-Access2, changed state to up
*May 20 20:53:20.832: %DIALER-6-UNBIND: Interface Vi2 unbound from profile Di0
*May 20 20:53:20.836: %LINK-3-UPDOWN: Interface Virtual-Access2, changed state to down
*May 20 20:53:42.909: %DIALER-6-BIND: Interface Vi2 bound to profile Di0
*May 20 20:53:42.913: %LINK-3-UPDOWN: Interface Virtual-Access2, changed state to up
*May 20 20:53:45.249: %DIALER-6-UNBIND: Interface Vi2 unbound from profile Di0
*May 20 20:53:45.253: %LINK-3-UPDOWN: Interface Virtual-Access2, changed state to down

●DHCPサーバの設定

 下記URLを参照してください。
 DHCPの設定

 下記のように設定しました。
Router(config)#ip domain name bigbang.dyndns.org ← ドメイン名の指定
Router(config)#dns-server XXX.XXX.XXX.XXX XXX.XXX.XXX.YYY ← DNSサーバを指定
Router(config)#ip dhcp excluded-address 192.168.0.1 192.168.010
  ↑ 配布除外アドレスを指定(その1)
Router(config)#ip dhcp excluded-address 192.168.0.245 192.168.0.254
  ↑ 配布除外アドレスを指定(その2)
Router(config)#ip dhcp pool local ← ip dhcp poolを定義
Router(config)#network 192.168.0.0/24 ← 配布アドレスの範囲を指定
Router(config)#default-router 192.168.0.254 ← デフォルトゲートウェイを指定
 PPPoEの場合、指定するDNSサーバはここに契約しているプロバイダから指示されているIPアドレスを指定します。。
 それでも不明な場合は、XPのPPPoEクライアントで接続し、接続後、ipconfig /allで確認すればDNSサーバのIPアドレスが判明します。そのIPアドレスを指定すればWeb等見ることができるようになります。