How to Create a Centralized Log Server with Rsyslog in CentOS/RHEL 7

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.95/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Matei Cezar says:

    The point 5 code lines should shoud have the following conetent:

    $template RemoteLogs,”/var/log/%HOSTNAME%/%PROGRAMNAME%.log”
    *.* ?RemoteLogs

    and the next template:

    $template FromIp,”/var/log/%FROMHOST-IP%.log”
    *.* ?FromIp

  2. IWO says:

    Hellow Matei:

    # mkdir /var/log/rsyslog
    # cp -p /etc/rsyslog.conf	/etc/rsyslog.conf.original
    # vi /etc/rsyslog.conf
    $template RemoteLogs,"/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
    . ?RemoteLogs & ~

    netstat’s deprecation <– in Centos 7 from minimal Install

    Apparently in CentOS 7 netstat, which is part of the package net-tools has been officially deprecated, so you should be using ss (part of the package iproute2), going forward.

    # yum provides /usr/sbin/ss		OR		# yum whatprovides /usr/sbin/ss
    Complementos cargados:fastestmirror
    Loading mirror speeds from cached hostfile
    iproute-3.10.0-74.el7.x86_64 : Advanced IP routing and network device configuration tools
    Repositorio        : @base
    Resultado obtenido desde:
    Nombre del archivo    : /usr/sbin/ss
    # ss -tulpn | grep rsyslog
    udp    UNCONN     0      0   *:514     *:*    users:(("rsyslogd",pid=10339,fd=3))
    udp    UNCONN     0      0   :::514    :::*   users:(("rsyslogd",pid=10339,fd=4))
    tcp    LISTEN     0      25  *:514    *:*    users:(("rsyslogd",pid=10339,fd=5))
    tcp    LISTEN     0      25  :::514    :::*   users:(("rsyslogd",pid=10339,fd=6))
    # getenforce
    # semanage -a -t syslogd_port_t -p udp 514	   <-- ERROR
    # semanage port -a -t syslogd_port_t -p udp 514	   <-- Sintaxis OK
    bash: semanage: no se encontró la orden		   <-- in Centos 7 
    # yum -y install policycoreutils-python
    # yum whatprovides /usr/sbin/semanage
    Complementos cargados:fastestmirror
    Loading mirror speeds from cached hostfile
    policycoreutils-python-2.5-11.el7_3.x86_64 : SELinux policy core 
    python utilities
    Repositorio        : @updates
    Resultado obtenido desde:
    Nombre del archivo    : /usr/sbin/semanage
    # semanage port	-a -t syslogd_port_t -p udp 514
    ValueError: El puerto udp/514 ya está definido		<-- Is it OK?
    # semanage port -a -t syslogd_port_t -p tcp 514
    ValueError: El puerto tcp/514 ya está definido		<-- Is it OK?
    # semanage port -l| grep syslog			<-- Is it OK?
    syslog_tls_port_t              tcp      6514
    syslog_tls_port_t              udp      6514
    syslogd_port_t                 tcp      601
    syslogd_port_t                 udp      514, 601
    # firewall-cmd --get-default-zone
    public						<-- Is it OK?
    # firewall-cmd --permanent --add-port=514/tcp
    # firewall-cmd --permanent --add-port=514/udp
    # firewall-cmd --reload
    # firewall-cmd --list-all
    public (active)
    target: default
    icmp-block-inversion: no
    interfaces: ens33
    services: dhcpv6-client ssh
    ports: 514/tcp 514/udp	<-- Is it OK?
    masquerade: no
    rich rules: 


  3. Mauro Formigoni Junior says:

    There is a little typo on Step 1, probably resulted of copy-paste.
    The command to start rsyslog is # systemctl START rsyslog.service instead of STATUS.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *