【検証】CiscoルータをSyslogサーバに接続し、ログ転送してみた

ネットワーク

今回はCiscoルータをSyslogサーバに接続し、ログを転送してみたいと思います。

 

 

検証環境

 

Ciscoルータ1台、Syslog転送用のサーバ1台用意しました。

SyslogサーバのIPアドレスは「192.168.1.100/24」、CiscoルータのIPアドレスを「192.168.1.1/24」に設定し、その間を接続した際にログ転送できることをゴールにしたいと思います。

 

 

Ciscoルータの初期設定

Router#show running-config 
Building configuration...

Current configuration : 553 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

 

現在の設定で「show logging」を入力すると、こんな感じの出力になります。

Router#show logging 
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited,
          0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.


No Inactive Message Discriminator.


    Console logging: level debugging, 2 messages logged, xml disabled,
          filtering disabled
    Monitor logging: level debugging, 2 messages logged, xml disabled,
          filtering disabled
    Buffer logging:  disabled, xml disabled,
          filtering disabled

    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped
    Trap logging: level informational, 2 message lines logged
Router#

 

ちなみに、デフォルトではログバッファサイズは4,096バイトになっています。

 

これでは障害が発生して大量にログが出力された際に古いログが消えてしまい、トラブルシューティングが行えない可能性があるのでSyslogサーバに転送しておく必要があります。

 

また、Ciscoルータ自体のバッファ値も変更できるため、後ほど変更しておきたいと思います。

 

スポンサーリンク

 

 

Ciscoルータの設定

まずはSyslogサーバと接続するインタフェースを作ります。

FE0/0にIPアドレス「192.168.1.1/24」を設定し、「no shutdown」で解放します。

Router#
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown 
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#

 

SyslogサーバのIPアドレス「192.168.1.100」を指定します。

Router(config)#
Router(config)#logging host 192.168.1.100
Router(config)#

 

ログのバッファサイズはデフォルト値「4096」の20倍にあたる「81920」を設定しておきます。

Router(config)#
Router(config)#logging buffered 81920
Router(config)#

 

 

動作確認

では、動作確認をしてみます。

ログを出力させるため、デフォルトで設定されているVLAN1を「no shutdown/shutdown」してみます。

Router(config)#
Router(config)#int vlan 1
Router(config-if)#no shutdown 
Router(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
Router(config-if)#
Router(config-if)#shutdown 
Router(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to administratively down
Router(config-if)#

 

その後、Syslogサーバ側で確認すると確かにログが転送されていました。

- 192.168.1.1 %LINK-5-CHANGED: Interface Vlan1, changed state to up
- 192.168.1.1 %LINK-5-CHANGED: Interface Vlan1, changed state to administratively down

 

先ほどと同様に「show logging」コマンドを入力してみると下記のような表示に変化します。

Router#
Router#show logging 
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited,
          0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.


No Inactive Message Discriminator.


    Console logging: level debugging, 11 messages logged, xml disabled,
          filtering disabled
    Monitor logging: level debugging, 11 messages logged, xml disabled,
          filtering disabled
    Buffer logging:  level debugging, 0 messages logged, xml disabled,
          filtering disabled

    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped
    Trap logging: level informational, 11 message lines logged
        Logging to 192.168.1.100  (udp port 514,  audit disabled,
             authentication disabled, encryption disabled, link up),
             9 message lines logged,
             0 message lines rate-limited,
             0 message lines dropped-by-MD,
             xml disabled, sequence number disabled
             filtering disabled
Log Buffer (81920 bytes):
Router#

 

Syslogサーバとして192.168.1.100が設定されていること、ログバッファサイズが81,920bytesに変更されていることを確認することができます。

 

スポンサーリンク

 

 

Ciscoルータの設定済みコンフィグ

Router#show running-config 
Building configuration...

Current configuration : 588 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
logging 192.168.1.100
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

 

最後に

今回はCiscoルータのログをSyslogサーバに転送することを目標に検証をしてみました。

 

しかし、転送されたログを確認すると肝心なタイムスタンプがなかったので、次回はタイムスタンプ付きのログを転送できるように設定を見直してみようと思います。

 

※2022年12月21日追記

タイムスタンプを付与してシスログを飛ばすコンフィグについては下記事をご覧ください。

【検証】CiscoルータをNTPサーバにして配下機器で時刻同期してみた
今回はCiscoルータをNTPサーバにして時刻同期しようと思います。  検証環境 前回の記事でCiscoルータをNTPサーバと同期させました。 今回はさらにもう1台C...

 

 

勉強教材

コメント

タイトルとURLをコピーしました