huawei switch:
#指定发送消息基本,表示从0-7都发送
info-centersourcedefaultchannel2logleveldebugging
#指定从哪个接口发送
info-centerloghostsourceVlanif1
#指定远程syslog服务器ip
info-centerloghost x.x.x.x
Centos Server:
vim /etc/rsyslog.conf
#启用udp 514端口监听。
$ModLoadimudp
$UDPServerRun514
#把来自两个交换机的日志分别放入到指定的log文件中。
:fromhost-ip,isequal,"x.x.x.x"/var/log/switch01.log
:fromhost-ip,isequal,"x.x.x.x"/var/log/switch02.log
#重启rsyslog服务
service rsyslog restart
测试:
在交换机上执行任何命令都被记录下来,比如:
#tail -f/var/log/switch01.log
May516:17:27switch01%%01SHELL/6/DISPLAY_CMDRECORD(s)[1]:Recordeddisplaycommandinformation.(Task=VT0,Ip=x.x.x.x,VpnName=,User=**,AuthenticationMethod="Password",Command="displayinfo-centerstatistics")
May516:17:40switch01%%01SHELL/6/DISPLAY_CMDRECORD(s)[2]:Recordeddisplaycommandinformation.(Task=VT0,Ip=x.x.x.x,VpnName=,User=**,AuthenticationMethod="Password",Command="displaycurrent-configuration")