跳转至主要内容

OpenVOS架构使用了几个独立的系统:用于X25通信的NIO,光纤通道磁盘阵列控制器,用于供电的UPS,用于RSN over IP的RSN Internet Console Server,以及允许所有这些系统在专用以太网/IP网络上通信的维护网络以太网交换机。这些系统由各种OpenVOS进程监控,以确保它们正常运行。但有些事件,如用户登录,则不被监控。RSN控制台和网络交换机可以选择在有人登录或试图登录时向日志服务器发送消息。由于网络交换机只连接到Stratus 模块,所以在Stratus 模块上运行一个日志服务器是有意义的。为此,我创建了一个非常简单的日志服务器,它只需将收到的消息以及日期时间戳和发送消息的主机的IP地址写入标准输出。通过将服务器作为一个启动的进程来运行,消息可以保存到进程的out文件中。

网络交换机的例子
有可能是被授权的人只是在以root身份登录网络交换机时,输入root密码时出了问题,又可能是他们真的很会猜密码。


2011-10-02 11:55:39 : 10.10.1.75 :>%AAA-W-REJECT:新的telnet连接使用
+r root, source 10.10.1.1 destination 10.10.1.75 REJECTED

2011-10-02 11:56:03 : 10.10.1.75 :>%AAA-W-REJECT:新的telnet连接使用
+r root, source 10.10.1.1 destination 10.10.1.75 REJECTED

2011-10-02 11:56:08 : 10.10.1.75 :>%AAA-I-CONNECT:用户的CLI会话
+ot over telnet , source 10.10.1.1 destination 10.10.1.75 ACCEPTED

有人在这里猜测系统管理员的用户ID。


2011-10-02 12:03:13 : 10.10.1.75 :>%AAA-W-REJECT:新的telnet连接使用
+r admin, source 10.10.1.1 destination 10.10.1.75 REJECTED

2011-10-02 12:03:30 : 10.10.1.75 :>%AAA-W-REJECT:新的telnet连接使用
+r sysadmin, source 10.10.1.1 destination 10.10.1.75 REJECTED

2011-10-02 12:04:39 : 10.10.1.75 :>%AAA-W-REJECT:新的telnet连接使用
+r 管理员,来源 10.10.1.1 目的地 10.10.1.75 REJECTED

除了用户登录外,当配置被更改时,网络交换机也会进行报告


2011-10-02 15:16:29 : 10.10.1.75 :>%COPY-I-FILECPY:文件复制------源代码运行
+ning-config目标URL flash://startup-config。

2011-10-02 15:16:43 : 10.10.1.75 :>%COPY-N-TRAP:复制操作已完成
+ed成功

而且它还会报告链接上下的信息,在排除通信问题时非常有用。


2011-10-02 15:49:17 : 10.10.1.75 :>%LINK-W-Down: 2/e24

2011-10-02 15:49:20 : 10.10.1.75 :>%LINK-I-Up:  2/e24
  RSN互联网控制台服务器的例子
该模块有人连接到RSN控制台并以root身份登录,输入密码错误两次后。


2011-10-02 12:11:03 : 10.10.1.200 : in.telnetd[2942]: connect from 10.10.1.1 (10.
+.10.1.1)
2011-10-02 12:11:03 : 10.10.1.200 : telnetd[2942]: doit: getaddrinfo:暂时的
+解决名称问题失败
2011-10-02 12:11:07 : 10.10.1.200 : login[2943]: invalid password for `root' on
+`ttyp0' from `10.10.1.1'
2011-10-02 12:11:15 : 10.10.1.200 : login[2943]: invalid password for `root' on
+`ttyp0' from `10.10.1.1'
2011-10-02 12:11:35 : 10.10.1.200 : login[2945]: root login on `ttyp0' from `10'。
+.10.1.1'

请注意,如果使用无效的用户ID进行尝试,RSN控制台将报告一个UNKNOWN的用户ID。


2011-10-02 12:12:31 : 10.10.1.200 : in.telnetd[2946]: connect from 10.10.1.1 (10.
+.10.1.1)
2011-10-02 12:12:32 : 10.10.1.200 : telnetd[2946]: doit: getaddrinfo:暂时的
+解决名称问题失败
2011-10-02 12:12:37 : 10.10.1.200 : login[2947]: invalid password for `UNKNOWN'
+on `ttyp0' from `10.10.1.1'
2011-10-02 12:12:45 :10.10.1.200 : login[2947]: invalid password for `UNKNOWN' (无效密码)
从"10.10.1.1"+上"ttyp0"。
2011-10-02 12:12:54 : 10.10.1.200 : login[2947]: invalid password for `UNKNOWN'
+对`10.10.1.1'的`ttyp0'进行检查。

当使用有效用户 ID rsn_admin 登录时,RSN 控制台将不会报告。但是,您仍然可以看到连接。rsn_admin 用户 ID 无权更改任何系统配置文件。如果rsn_admin用户试图使用su命令改变为root用户,将会被记录下来。


2011-10-02 12:15:37 : 10.10.1.200 : in.telnetd[2957]: connect from 10.10.1.1 (10.
+.10.1.1)
2011-10-02 12:15:38 : 10.10.1.200 : telnetd[2957]: doit: getaddrinfo:暂时的
+解决名称问题失败
2011-10-02 12:15:54 : 10.10.1.200 : su[2959]:+ ttyp0 rsn_admin-root
2011-10-02 12:15:54 : 10.10.1.200 : PAM_unix[2959]:(su) session opened for user
+ root by rsn_admin(uid=500)

正如会失败的尝试。


2011-10-02 12:19:50 : 10.10.1.200 : PAM_unix[2972]: 身份验证失败; rsn_
+admin(uid=500) -> su服务的root权限。
2011-10-02 12:19:52 : 10.10.1.200 : su[2972]: pam_authenticate:认证f_authenticate: Authentication f
+ 失败
2011-10-02 12:19:52 : 10.10.1.200 : su[2972]: - ttyp0 rsn_admin-root

 

要配置网络交换机向OpenVOS模块发送日志消息,需要以root身份登录交换机,执行日志命令,然后保存新的配置。

telnet 10.10.1.75          
试试...
连接到10.10.1.75。
转义字符是'^]'。

用户名:root
密码:******

console# 配置
控制台(配置)# 记录 10.10.1.1
控制台(配置)#

console# copy running-config startup-config

 

要配置 RSN 控制台向 OpenVOS 模块发送日志信息,需要以 root 身份登录控制台,并使用 "syslogd -R 10.10.1.1:514" 命令启动 syslogd 进程。为了确保syslogd进程在重启后被启动,必须修改/etc/tc.d/rc.local文件。

telnet 10.10.1.200
Trying...
Connected to 10.10.1.200.
Escape character is '^]'.

Moxa Embedded Linux, Professional Edition
Linux/armv5teb 2.4.18_mvl30-ixdp425

azvos login: root
Password:
Welcome to

    ___  _____  __        _______    _____                   __
   / _ / __/ |/ / ____  /  _/ _   / ___/__  ___  ___ ___  / /__
  / , _/ /    / /___/ _/ // ___/ / /__/ _ / _ (_-</ _ / / -_)
 /_/|_/___/_/|_/       /___/_/     ___/___/_//_/___/___/_/__/ 

 Authorized Users Only!

root@azvos:~# syslogd -R 10.10.1.1:514
root@azvos:~# 
root@azvos:~# 
root@azvos:~# 
root@azvos:~# cd /etc/rc.d
root@azvos:/etc/rc.d# cp rc.local rc.local.bak
root@azvos:/etc/rc.d# echo syslogd -R 10.10.1.1:514 >> rc.local
root@azvos:/etc/rc.d# tail rc.local
fi
/etc/init.d/ssh start
/etc/init.d/apache stop
/etc/init.d/portmap stop
rm -f /rsn/call.log
/rsn/callhome &
lcmmessage -c -m "   Welcome to   " -l
lcmmessage -m " RSN-IP Console " -l
cat /etc/motd
syslogd -R 10.10.1.1:514
root@azvos:/etc/rc.d#

 

假设你得到了和上面一样的输出,你可以用"rm rc.local.bak"删除rc.local.bak文件。

在设备上设置好日志后,你需要在Stratus 模块上运行logd程序。 我建议用下面的命令宏启动该程序。日志文件将被命名为logd.(date).(time).out。如果由于某种原因,已经有一个同名的文件存在,那么它将被重命名为logd.(date).(time).old.out。如果已经有一个后缀为.old.out的文件,则会被删除。考虑到时间戳是秒,这不太可能。out文件有隐式锁定设置,所以文件可以在任何时候被读取。请注意,out文件将永远增长,所以你需要进行一些维护,或者你可以修改程序,使其更智能地处理输出。



& start_logd.cm从这里开始
&
1.00版本 11-11-02
& [email protected]
&
& 这个脚本创建了一个日志文件,设置了隐式锁定,并启动了logd。
和进程。进程不会正常终止,日志文件中含有
&发展潜力非常大。
&
&
本软件以"现状"为基础提供,没有任何保证或承诺。
以及任何形式的支持。作者特别声明任何暗示的。
对适销性或任何特定目的的适用性的保证。
本免责声明适用于,尽管任何口头陈述的任何。
&实物由作者或其他任何人提供。
&
&set DT (date).(time)
&if (existence logd.&DT&.out)
&then !rename logd.&DT&.out logd.&DT&.old.out -delete
!"create_file logd.&DT&.out"。
!"set_implicit_locking logd.&DT&.out"。
start_process logd -output_path logd.&DT&.out -privileged -process_name logd。
&
& start_logd.cm在此结束

 

任何最后这里是程序。



/* logd.c starts here

   Version 1.00 11-11-02
   [email protected]

   This software is provided on an "AS IS" basis, WITHOUT ANY WARRANTY OR
   ANY SUPPORT OF ANY KIND. The AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE.
   This disclaimer applies, despite any verbal representations of any
   kind provided by the author or anyone else.
*/

#define _POSIX_SOURCE

#include <sys/select.h>
#include <prototypes/inet_proto.h>
#include <stdlib.h>
#include <string.h>
#include <c_utilities.h>
#include <errno.h>
#include <time.h>

#define BUFFERLEN 10000
#define bzero(s, len)             memset((char *)(s), 0, len)

int errno;

getCurrentDateTime (char * szDT)
{
time_t tTime;
struct tm *tmLT;

tTime = time ((time_t *) 0);
tmLT = localtime (&tTime);

sprintf (szDT, "%4ld-%02ld-%02ld %02ld:%02ld:%02ld",
          tmLT -> tm_year+1900,
          tmLT -> tm_mon,
          tmLT -> tm_mday,
          tmLT -> tm_hour,
          tmLT -> tm_min,
          tmLT -> tm_sec);
}

main (argc, argv)
int    argc;
char   *argv [];

{
 struct sockaddr_in serv_addr;
 struct sockaddr_in cli_addr;
 int clilen = sizeof (cli_addr);

 int zeroCount = 0;
 int socks0;
 int recvBytes;

 char szSender [16];
 char  szDateTime [32];
 char szMessage [BUFFERLEN];
 short portNumber;

 if (argc == 1)  /* no arguments - use the default of 514 */
    {
    portNumber = 514;
    }
 else
 if (argc == 2) /* one argument, must be the expected port number */
    {
    portNumber = atoi (argv [1]);
    if (portNumber == 0)
       {
       printf ("nn%s argument was not the expected port number", argv [1]);
       printf ("nUsage: logd [port number, default = 514]n");
       exit (-1);
       }
    }
 else /* more than one argument gets a usage message */
    {
    printf ("nnToo many arguments");
    printf ("nUsage: logd [port number, default = 514]n");
    exit (-1);
    }

/* Leting you know what argument values will actually be used */

 printf ("logd %dnn", portNumber);

 if ((socks0 = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
    {
    perror ("logd: can't create dgram socket");
    exit (errno);
    }

/* build a sockaddr structure holding the address we will bind to. The IP
   address is INADDR_ANY meaning we will listen on all active IP addresses */

 bzero ( (char *) &serv_addr, sizeof (serv_addr));
 serv_addr.sin_family        = AF_INET;
 serv_addr.sin_addr.s_addr   = htonl (INADDR_ANY);
 serv_addr.sin_port          = htons (portNumber);

/* now bind to the address and port */

 if (bind (socks0, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0)
    {
    perror ("logd: can't bind local address");
    exit (errno);
    }

/* main loop just does a recv, blocking until something is available to read.
   Assuming we receive at least 1 byte we get the current date-time,
   convert the senders IP address to a printable string and print the
   date-time, address and message starting at the 5th character position.
   The first four characters of a syslog message are <NN> where NN is a
   severity and facility code. These can be used for message filtering. Since
   this program doesn't do any filtering I just skip them. */
 while (1)
   {
    recvBytes=recvfrom(socks0,szMessage, BUFFERLEN, 0,
          (struct sockaddr *) &cli_addr, &clilen);
    if (recvBytes > 0)
       {
       getCurrentDateTime ((char *) &szDateTime);
       strcpy (szSender, inet_ntoa ((struct in_addr) cli_addr.sin_addr));
       szMessage [recvBytes] = 0;
       printf ("%s : %s : %sn", szDateTime, szSender, &szMessage[4]);
       zeroCount = 0;
       }
    else
    if (recvBytes < 0) /* in the event of an error report it and exit */
       {
       getCurrentDateTime ((char *) &szDateTime);
       printf ("%s : Error %d returned - exitingn", szDateTime, errno);
       exit (errno);
       }
    else  /* I can't think of any reason we would be getting null messages */
       {  /* but if we get a stream of them we would silently loop. This */
       zeroCount++;          /* forces out a message if we get 100 null */
       if (zeroCount > 99)   /* messages in a row */
          {
          getCurrentDateTime ((char *) &szDateTime);
          strcpy (szSender, inet_ntoa ((struct in_addr) cli_addr.sin_addr));
          printf ("%s : %s %sn", szDateTime,
               "We have received 100 null messages, the last one from",
               szSender);
          zeroCount = 0;
          }
       }
   }
}

/* logd.c ends here */

 

© 2024Stratus Technologies.