Syslog-ng

Syslog-ng - Linux et OS Alternatifs

Marsh Posté le 05-10-2004 à 10:44:32    

Salut,
 
J'utilise le package syslog-ng au lieu de syslog pour avoir plus de precision dans ma gestion des logs. Par contre j'ai un petit probleme avec, mes logs de firewall se retrouve dans le fichier de destination + dans ma console, ca n'arrete pas de monté dans la console :o avec un dmesg on arrive a voir les logs firewall aussi ^^  
 

Code :
  1. #
  2. # Configuration file for syslog-ng under Debian
  3. #
  4. # attempts at reproducing default syslog behavior
  5. # the standard syslog levels are (in descending order of priority):
  6. # emerg alert crit err warning notice info debug
  7. # the aliases "error", "panic", and "warn" are deprecated
  8. # the "none" priority found in the original syslogd configuration is
  9. # only used in internal messages created by syslogd
  10. ######
  11. # options
  12. options {
  13.         #
  14.         long_hostnames(0);
  15.         # the time to wait before a died connection is re-established
  16.         # (default is 60)
  17.         time_reopen(10);
  18.         # the time to wait before an idle destination file is closed
  19.         # (default is 60)
  20.         time_reap(360);
  21.         # the number of lines buffered before written to file
  22.         # you might want to increase this if your disk isn't catching with
  23.         # all the log messages you get or if you want less disk activity
  24.         # (say on a laptop)
  25.         # (default is 0)
  26.         #sync(0);
  27.         # the number of lines fitting in the output queue
  28.         log_fifo_size(2048);
  29.         # enable or disable directory creation for destination files
  30.         create_dirs(yes);
  31.         # default owner, group, and permissions for log files
  32.         # (defaults are 0, 0, 0600)
  33.         #owner(root);
  34.         group(adm);
  35.         perm(0640);
  36.         # default owner, group, and permissions for created directories
  37.         # (defaults are 0, 0, 0700)
  38.         #dir_owner(root);
  39.         #dir_group(root);
  40.         dir_perm(0755);
  41.         # enable or disable DNS usage
  42.         # syslog-ng blocks on DNS queries, so enabling DNS may lead to
  43.         # a Denial of Service attack
  44.         # (default is yes)
  45.         use_dns(no);
  46.         # maximum length of message in bytes
  47.         # this is only limited by the program listening on the /dev/log Unix
  48.         # socket, glibc can handle arbitrary length log messages, but -- for
  49.         # example -- syslogd accepts only 1024 bytes
  50.         # (default is 2048)
  51.         #log_msg_size(2048);
  52. };
  53. ######
  54. # sources
  55. # all known message sources
  56. source s_all {
  57.         # message generated by Syslog-NG
  58.         internal();
  59.         # standard Linux log source (this is the default place for the syslog()
  60.         # function to send logs to)
  61.         unix-stream("/dev/log" );
  62.         # messages from the kernel
  63.         file("/proc/kmsg" log_prefix("kernel: " ));
  64.         # use the above line if you want to receive remote UDP logging messages
  65.         # (this is equivalent to the "-r" syslogd flag)
  66.         # udp();
  67. };
  68. ######
  69. # destinations
  70. # some standard log files
  71. destination df_auth { file("/var/log/auth.log" ); };
  72. destination df_syslog { file("/var/log/syslog" ); };
  73. destination df_cron { file("/var/log/cron.log" ); };
  74. destination df_daemon { file("/var/log/daemon.log" ); };
  75. destination df_kern { file("/var/log/kern.log" ); };
  76. destination df_lpr { file("/var/log/lpr.log" ); };
  77. destination df_mail { file("/var/log/mail.log" ); };
  78. destination df_user { file("/var/log/user.log" ); };
  79. destination df_uucp { file("/var/log/uucp.log" ); };
  80. destination df_firewall { file("/var/log/firewall/firewall.log" ); };
  81. destination df_pureftpd { file("/var/log/pure-ftpd/ftp.log" ); };
  82. destination df_spamd { file("/var/log/spam/spam.log" ); };
  83. destination df_ssh { file("/var/log/ssh/ssh.log" ); };
  84. # these files are meant for the mail and news systems log files
  85. # and provide re-usable destinations for {mail,news,...}.info,
  86. # {mail,news,...}.notice, etc.
  87. destination df_facility_dot_info { file("/var/log/$FACILITY.info" ); };
  88. destination df_facility_dot_notice { file("/var/log/$FACILITY.notice" ); };
  89. destination df_facility_dot_warn { file("/var/log/$FACILITY.warn" ); };
  90. destination df_facility_dot_err { file("/var/log/$FACILITY.err" ); };
  91. destination df_facility_dot_crit { file("/var/log/$FACILITY.crit" ); };
  92. # some more classical and useful files found in standard syslog configurations
  93. destination df_debug { file("/var/log/debug" ); };
  94. destination df_messages { file("/var/log/messages" ); };
  95. # pipes
  96. # a console to view log messages under X
  97. destination dp_xconsole { pipe("/dev/xconsole" ); };
  98. # consoles
  99. # this will send messages to everyone logged in
  100. destination du_all { usertty("*" ); };
  101. ######
  102. # filters
  103. # all messages from the auth and authpriv facilities
  104. filter f_auth { facility(auth, authpriv); };
  105. # all messages except from the auth and authpriv facilities
  106. filter f_syslog { not facility(auth, authpriv) and not match(" ### Stealth Scan ### " ) and not match(" ### XMAS Scan ### " ) and not match(" ### SYN/RST Scan ### " ) and not match(" ### Stealth FIN Scan ### " ) and not match(" ### SYN/FIN Scan ### " ) and not match(" ### Null Scan ### " ) and not match(" ### Ping Scan ### " ) and not match("## SCAN SYN/ACK ## " ) and not match("## INPUT TCP sans SYN ## " ) and not match("## INVALID INPUT ## " ) and not match("## BAD INPUT ## " ) and not match("## Connexion FTP ## " ) and not match("## Connexion SSH ## " ) and not match("## Identd ## " ) and not match("pure-ftpd" ) and not match("spamd" ); };
  107. # respectively: messages from the cron, daemon, kern, lpr, mail, news, user,
  108. # and uucp facilities
  109. filter f_cron { facility(cron); };
  110. filter f_daemon { facility(daemon); };
  111. filter f_kern { facility(kern) and not match(" ### Stealth Scan ### " ) and not match(" ### XMAS Scan ### " ) and not match(" ### SYN/RST Scan ### " ) and not match(" ### Stealth FIN Scan ### " ) and not match(" ### SYN/FIN Scan ### " ) and not match(" ### Null Scan ### " ) and not match(" ### Ping Scan ### " ) and not match("## SCAN SYN/ACK ## " ) and not match("## INPUT TCP sans SYN ## " ) and not match("## INVALID INPUT ## " ) and not match("## BAD INPUT ## " ) and not match("## Connexion FTP ## " ) and not match("## Connexion SSH ## " )  and not match("## Identd ## " ) and not match("pure-ftpd" ) and not match("spamd" ); };
  112. filter f_lpr { facility(lpr); };
  113. filter f_mail { facility(mail); };
  114. filter f_news { facility(news); };
  115. filter f_user { facility(user); };
  116. filter f_uucp { facility(uucp); };
  117. # some filters to select messages of priority greater or equal to info, warn,
  118. # and err
  119. # (equivalents of syslogd's *.info, *.warn, and *.err)
  120. filter f_at_least_info { level(info..emerg); };
  121. filter f_at_least_notice { level(notice..emerg); };
  122. filter f_at_least_warn { level(warn..emerg); };
  123. filter f_at_least_err { level(err..emerg); };
  124. filter f_at_least_crit { level(crit..emerg); };
  125. # all messages of priority debug not coming from the auth, authpriv, news, and
  126. # mail facilities
  127. filter f_debug { level(debug) and not facility(auth, authpriv, news, mail); };
  128. # all messages of info, notice, or warn priority not coming form the auth,
  129. # authpriv, cron, daemon, mail, and news facilities
  130. filter f_messages {
  131.         level(info,notice,warn)
  132.             and not facility(auth,authpriv,cron,daemon,mail,news)and not match (".*IN=.*OUT=.*MAC=.*" ) and not match ("pure-ftpd*" ) and not match("spamd*" ) and not match("syslog-ng*:*STATS:*dropped" ); };
  133. # messages with priority emerg
  134. filter f_emerg { level(emerg); };
  135. # complex filter for messages usually sent to the xconsole
  136. filter f_xconsole {
  137.     facility(daemon,mail)
  138.         or level(debug,info,notice,warn)
  139.         or (facility(news)
  140.                 and level(crit,err,notice));
  141. };
  142. filter f_iptables { match("IN=.*OUT=.*MAC=.*" ); };
  143. filter f_pureftpd { match("pure-ftpd*" ); };
  144. filter f_spamd { match("spamd*" ); };
  145. filter f_ssh { match("sshd*" ); };
  146. ######
  147. # logs
  148. # order matters if you use "flags(final);" to mark the end of processing in a
  149. # "log" statement
  150. # these rules provide the same behavior as the commented original syslogd rules
  151. # auth,authpriv.*                 /var/log/auth.log
  152. log {
  153.         source(s_all);
  154.         filter(f_auth);
  155.         destination(df_auth);
  156. };
  157. # *.*;auth,authpriv.none          -/var/log/syslog
  158. log {
  159.         source(s_all);
  160.         filter(f_syslog);
  161.         destination(df_syslog);
  162. };
  163. # this is commented out in the default syslog.conf
  164. # cron.*                         /var/log/cron.log
  165. #log {
  166. #        source(s_all);
  167. #        filter(f_cron);
  168. #        destination(df_cron);
  169. #};
  170. # daemon.*                        -/var/log/daemon.log
  171. log {
  172.         source(s_all);
  173.         filter(f_daemon);
  174.         destination(df_daemon);
  175. };
  176. # kern.*                          -/var/log/kern.log
  177. log {
  178.         source(s_all);
  179.         filter(f_kern);
  180.         destination(df_kern);
  181. };
  182. # lpr.*                           -/var/log/lpr.log
  183. log {
  184.         source(s_all);
  185.         filter(f_lpr);
  186.         destination(df_lpr);
  187. };
  188. # mail.*                          -/var/log/mail.log
  189. log {
  190.         source(s_all);
  191.         filter(f_mail);
  192.         destination(df_mail);
  193. };
  194. # user.*                          -/var/log/user.log
  195. log {
  196.         source(s_all);
  197.         filter(f_user);
  198.         destination(df_user);
  199. };
  200. # uucp.*                          /var/log/uucp.log
  201. log {
  202.         source(s_all);
  203.         filter(f_uucp);
  204.         destination(df_uucp);
  205. };
  206. # mail.info                       -/var/log/mail.info
  207. log {
  208.         source(s_all);
  209.         filter(f_mail);
  210.         filter(f_at_least_info);
  211.         destination(df_facility_dot_info);
  212. };
  213. # mail.warn                       -/var/log/mail.warn
  214. log {
  215.         source(s_all);
  216.         filter(f_mail);
  217.         filter(f_at_least_warn);
  218.         destination(df_facility_dot_warn);
  219. };
  220. # mail.err                        /var/log/mail.err
  221. log {
  222.         source(s_all);
  223.         filter(f_mail);
  224.         filter(f_at_least_err);
  225.         destination(df_facility_dot_err);
  226. };
  227. # news.crit                       /var/log/news/news.crit
  228. log {
  229.         source(s_all);
  230.         filter(f_news);
  231.         filter(f_at_least_crit);
  232.         destination(df_facility_dot_crit);
  233. };
  234. # news.err                        /var/log/news/news.err
  235. log {
  236.         source(s_all);
  237.         filter(f_news);
  238.         filter(f_at_least_err);
  239.         destination(df_facility_dot_err);
  240. };
  241. # news.notice                     /var/log/news/news.notice
  242. log {
  243.         source(s_all);
  244.         filter(f_news);
  245.         filter(f_at_least_notice);
  246.         destination(df_facility_dot_notice);
  247. };
  248. # *.=debug;\
  249. #         auth,authpriv.none;\
  250. #         news.none;mail.none     -/var/log/debug
  251. log {
  252.         source(s_all);
  253.         filter(f_debug);
  254.         destination(df_debug);
  255. };
  256. # *.=info;*.=notice;*.=warn;\
  257. #         auth,authpriv.none;\
  258. #         cron,daemon.none;\
  259. #         mail,news.none          -/var/log/messages
  260. log {
  261.         source(s_all);
  262.         filter(f_messages);
  263.         destination(df_messages);
  264. };
  265. # *.emerg                         *
  266. log {
  267.         source(s_all);
  268.         filter(f_emerg);
  269.         destination(du_all);
  270. };
  271. # daemon.*;mail.*;\
  272. #         news.crit;news.err;news.notice;\
  273. #         *.=debug;*.=info;\
  274. #         *.=notice;*.=warn       |/dev/xconsole
  275. log {
  276.         source(s_all);
  277.         filter(f_xconsole);
  278.         destination(dp_xconsole);
  279. };
  280. # Firewall
  281. log {
  282.    source(s_all);
  283.    filter(f_iptables);
  284.    destination(df_firewall);
  285. };
  286. # FTP
  287. log {
  288.    source(s_all);
  289.    filter(f_pureftpd);
  290.    destination(df_pureftpd);
  291. };
  292. # Spam
  293. log {
  294.    source(s_all);
  295.    filter(f_spamd);
  296.    destination(df_spamd);
  297. };
  298. # SSH
  299. log {
  300.    source(s_all);
  301.    filter(f_ssh);
  302.    destination(df_ssh);
  303. };


 
et voici une des regles iptables pour le log:  
 

Code :
  1. iptables -A INPUT -p TCP --tcp-flags ! ALL SYN -m state --state NEW -m limit --limit 3/s -j LOG --log-tcp-option  --log-ip-options --log-level info --log-prefix "## INPUT TCP sans SYN ## "


 
Comment faire pour plus avoir mes logs firewall dans ma console et qu'il ne s'affiche plus avec la commande dmesg.
 
Merci


---------------
I dont have any solution, but I certainly admire the problem
Reply

Marsh Posté le 05-10-2004 à 10:44:32   

Reply

Marsh Posté le 05-10-2004 à 11:42:01    

installe ULOGD, et tu mets -j ULOG, t'auras tout dans les logs de ulog. (/var/log/ulogd.syslogmenu)

Reply

Marsh Posté le 05-10-2004 à 16:51:18    

Je ne peux pas, avec ulogd j'avais un grand prob, la date des logs était tjrs: Jan  1 01:00:00  

Code :
  1. Jan  1 01:00:00 Jupiter ## Connexion FTP ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=48 TOS=00 PREC=0x00 TTL=116 ID=12491 DF PROTO=TCP SPT=3242 DPT=21 SEQ=3110156186 ACK=0 WINDOW=16384 SYN URGP=0
  2. Jan  1 01:00:00 Jupiter ## INPUT TCP sans SYN ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=247 ID
  3. =51214 CE PROTO=TCP SPT=3922 DPT=445 SEQ=2627438016 ACK=0 WINDOW=0 RST URGP=0
  4. Jan  1 01:00:00 Jupiter ## BAD INPUT ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=247 ID=51214 CE
  5. PROTO=TCP SPT=3922 DPT=445 SEQ=2627438016 ACK=0 WINDOW=0 RST URGP=0
  6. Jan  1 01:00:00 Jupiter ## INPUT TCP sans SYN ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=247 ID
  7. =51592 CE PROTO=TCP SPT=3922 DPT=445 SEQ=2627438016 ACK=0 WINDOW=0 RST URGP=0
  8. Jan  1 01:00:00 Jupiter ## BAD INPUT ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=247 ID=51592 CE
  9. PROTO=TCP SPT=3922 DPT=445 SEQ=2627438016 ACK=0 WINDOW=0 RST URGP=0
  10. Jan  1 01:00:00 Jupiter ## INPUT TCP sans SYN ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=247 ID
  11. =52113 CE PROTO=TCP SPT=3922 DPT=445 SEQ=2627438016 ACK=0 WINDOW=0 RST URGP=0
  12. Jan  1 01:00:00 Jupiter #### SYN/FIN Scan #### IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=28 ID=39
  13. 426 CE PROTO=TCP SPT=21 DPT=21 SEQ=707015513 ACK=1005711576 WINDOW=1028 SYN FIN URGP=0
  14. Jan  1 01:00:00 Jupiter ## INPUT TCP sans SYN ## IN=eth0 OUT= MAC=***  SRC=*** DST=*** LEN=40 TOS=00 PREC=0x00 TTL=28 ID=
  15. 39426 CE PROTO=TCP SPT=21 DPT=21 SEQ=707015513 ACK=1005711576 WINDOW=1028 SYN FIN URGP=0


---------------
I dont have any solution, but I certainly admire the problem
Reply

Marsh Posté le 05-10-2004 à 17:55:24    

dmesg -n 1 ?


---------------
Intermittent du GNU
Reply

Marsh Posté le 05-10-2004 à 19:08:04    

Citation :

> > > I tried my logging rules with '--log-prefix "IPTables DROP:"'
> > > and use syslog-ng to filter them. If you google for iptables
> > > and syslog-ng there's some more help.
> > > What _I_ didn't figure out is, how to stop iptables from
> > > logging to standard-out;M syslog-ng seems only to additionally
> > > write it to my specified file.
> >  
> > Right, this is done by klogd.
> >  
> > man klogd
> >  
>  
> I typically add "-c 4" in KLOGD (/etc/init.d/klogd) to avoid the
> iptables logging to console.


Reply

Marsh Posté le 05-10-2004 à 19:47:14    

Ben le paquet klogd s'install avec syslogd. Syslog-ng depend pas de klogd et si jamais j'essaye de l'installé  

Code :
  1. Les paquets supplémentaires suivants seront installés :
  2.   sysklogd
  3. Les paquets suivants seront ENLEVÉS :
  4.   syslog-ng
  5. Les NOUVEAUX paquets suivants seront installés :
  6.   klogd sysklogd


 
Je pense pas que mon probleme a qlq chose avec klogd

Reply

Marsh Posté le 06-10-2004 à 10:56:47    

UP  :jap:


---------------
I dont have any solution, but I certainly admire the problem
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed