Skip to content

SNMP & Protocols

Syslog ports explained: 514 over UDP and TCP, and 6514 for TLS

Syslog listens on UDP port 514. That is the standard assignment, written down in RFC 5426, and it is where nearly every switch, router, firewall and printer sends by default. Syslog over plain TCP has no port of its own: by convention it uses 514 as well, although IANA lists TCP 514 for the old rsh service. Syslog over TLS uses TCP 6514, assigned by RFC 5425. The rule of thumb: UDP 514 for gear that can do nothing else, TLS on 6514 for anything that crosses a network you do not control, and plain TCP only where both ends agree on framing.

The small-network syslog build covers the server, per-device folders, rotation and clocks. This piece is about the wire: which syslog port carries which transport, how messages are separated on a TCP stream, and listener and firewall configs that match.

Which syslog port for which transport

Port Transport Defined by Framing Typical use
514/udp UDP RFC 5426, older practice in RFC 3164 one message per datagram network gear, appliances, most defaults
514/tcp TCP convention only; IANA lists it for rsh line feed or octet counting Linux relays, devices with a TCP option
601/tcp TCP IANA "syslog-conn", RFC 3195 BEEP in the RFC rare; some tools use it for RFC 5424 over plain TCP
6514/tcp TLS RFC 5425 octet counting, required anything crossing an untrusted network
6514/udp DTLS RFC 6012 one message per datagram rare

UDP 514: the default, and its limits

UDP is why syslog is everywhere. There is no connection and no state, so a device can fire off a message in the middle of a crash and forget it. The same properties cause the problems:

  • No delivery guarantee. A burst during an outage (an access layer flapping, a loop) can overflow the receiver's socket buffer, and those messages are gone. On Linux, the RcvbufErrors counter in /proc/net/snmp shows it happening; if it climbs, raise rcvbufSize on rsyslog's imudp input and the kernel's net.core.rmem_max.
  • No sender authentication. Anything that reaches the port can write lines into your logs under any hostname it likes.
  • Size. RFC 5426 requires receivers to accept 480 octets over IPv4 and 1,180 over IPv6, and says they should accept 2,048. Longer messages may be truncated, and stack traces rarely fit.
  • No encryption. Log lines carry usernames, addresses and sometimes worse.

None of that rules UDP out. On a management VLAN, for switches that offer nothing else, it is the right choice. It just should not leave the building.

TCP 514 and the framing problem

TCP fixes loss on the wire and lets the sender notice when the receiver is gone. It also adds a problem UDP never had: a connection is one long byte stream, so the receiver must know where each message ends. RFC 6587 documents the two methods in use. It is a Historic RFC, describing existing practice rather than setting a standard, which tells you how messy that practice was.

# Non-transparent framing: each message ends with a line feed
<38>1 2026-11-20T09:15:02Z fw1 sshd 812 - - Failed password for admin from 198.51.100.23
<38>1 2026-11-20T09:15:03Z fw1 sshd 812 - - Connection closed by 198.51.100.23

# Octet counting: length in bytes, one space, then exactly that many bytes
88 <38>1 2026-11-20T09:15:02Z fw1 sshd 812 - - Failed password for admin from 198.51.100.23
78 <38>1 2026-11-20T09:15:03Z fw1 sshd 812 - - Connection closed by 198.51.100.23

Line-feed framing breaks as soon as a message contains a line feed of its own: a multi-line stack trace arrives as twenty broken messages. Octet counting carries any content, but only when both ends speak it. A mismatch is easy to spot once you know the signs:

  • Every stored message starts with a number, such as 88 <38>1: the sender counts octets, the receiver expects line feeds.
  • Messages glued into one long line, or framing errors in the receiver's own log: the sender uses line feeds, the receiver expects counts.

rsyslog's imtcp accepts both on one port; octet-counted support is on by default and it recognizes each sender's style. Its omfwd sends line-feed framing unless you set TCP_Framing="octet-counted". In syslog-ng the source driver decides: network() expects line feeds, syslog() expects octet counting, and from version 4.9 syslog(transport(auto)) takes both on one port. Cisco IOS sends over TCP with logging host 192.0.2.10 transport tcp port 514; check your platform's documentation for its framing before pointing it at a strict receiver.

TLS on 6514

TLS adds encryption and lets each end prove who it is with a certificate. RFC 5425 assigns TCP 6514 and requires octet-counting framing inside the session. You need three things:

  1. A small private CA, or your existing internal one.
  2. A server certificate whose name matches what clients connect to, for example logs.example.net.
  3. A client certificate for each sender, so the server can refuse strangers.

Encryption without client certificates (rsyslog's anon mode, syslog-ng's optional-untrusted) still lets anyone who reaches the port send messages. It protects confidentiality, nothing more.

An rsyslog listener for all three

TLS in rsyslog needs the GnuTLS driver, packaged as rsyslog-gnutls on Debian, Ubuntu and the Red Hat family. Then create /etc/rsyslog.d/10-listeners.conf:

template(name="PerHost" type="string"
         string="/var/log/remote/%fromhost-ip%/messages.log")
ruleset(name="remote") {
    action(type="omfile" dynaFile="PerHost")
}

module(load="imudp")
module(load="imtcp")

input(type="imudp" port="514" ruleset="remote")
input(type="imtcp" port="514" ruleset="remote")
input(type="imtcp" port="6514" ruleset="remote"
      streamDriver.name="gtls" streamDriver.mode="1"
      streamDriver.authMode="x509/name"
      permittedPeer=["*.example.net"]
      streamDriver.caFile="/etc/rsyslog-tls/ca.pem"
      streamDriver.certFile="/etc/rsyslog-tls/logs.example.net.crt"
      streamDriver.keyFile="/etc/rsyslog-tls/logs.example.net.key")

The TLS settings sit on the 6514 input only, so TCP 514 stays plain. Per-input certificate files need rsyslog 8.2108 or newer; on older releases the three paths go in a global() block as DefaultNetstreamDriverCAFile, DefaultNetstreamDriverCertFile and DefaultNetstreamDriverKeyFile. With x509/name, only clients whose certificate names match permittedPeer get in. If you already have a remote ruleset or an imudp load from an earlier build, keep one copy: rsyslog refuses a module loaded twice.

sudo rsyslogd -N1
sudo systemctl restart rsyslog
sudo ss -tulpn | grep -E ':(514|6514)\b'

A client that forwards over TLS

On each Linux sender, install rsyslog-gnutls and add /etc/rsyslog.d/90-forward-tls.conf:

action(type="omfwd" target="logs.example.net" port="6514" protocol="tcp"
       StreamDriver="gtls" StreamDriverMode="1"
       StreamDriverAuthMode="x509/name"
       StreamDriverPermittedPeers="logs.example.net"
       streamDriver.CAFile="/etc/rsyslog-tls/ca.pem"
       streamDriver.CertFile="/etc/rsyslog-tls/web01.example.net.crt"
       streamDriver.KeyFile="/etc/rsyslog-tls/web01.example.net.key"
       TCP_Framing="octet-counted"
       template="RSYSLOG_SyslogProtocol23Format"
       queue.type="LinkedList" queue.filename="fwd_tls"
       queue.saveOnShutdown="on" action.resumeRetryCount="-1")

The client checks that the server certificate says logs.example.net, sends RFC 5424 messages with octet counting, and holds messages in a disk-assisted queue while the server is down instead of dropping them. That queue is the biggest practical gain over UDP.

The same listener in syslog-ng

source s_remote {
    network(transport("udp") port(514));
    network(transport("tcp") port(514) max-connections(200));
    syslog(transport("tls") port(6514) max-connections(200)
        tls(
            key-file("/etc/syslog-ng/tls/logs.example.net.key")
            cert-file("/etc/syslog-ng/tls/logs.example.net.crt")
            ca-file("/etc/syslog-ng/tls/ca.pem")
            peer-verify(required-trusted)
        )
    );
};

destination d_remote {
    file("/var/log/remote/${SOURCEIP}/messages.log" create-dirs(yes));
};

log { source(s_remote); destination(d_remote); };

Two details matter. The TLS listener uses syslog() because RFC 5425 senders count octets, while network() expects line feeds. And max-connections() defaults to 10 per listener, which a network with more than ten TCP senders hits on the first day. Run syslog-ng --syntax-only before restarting.

Firewall rules for syslog ports

Open only what you use, and only from where you expect it: 514 from the management networks, 6514 from wherever TLS senders live. With ufw:

sudo ufw allow from 10.20.0.0/16 to any port 514 proto udp
sudo ufw allow from 10.20.0.0/16 to any port 514 proto tcp
sudo ufw allow from 203.0.113.0/24 to any port 6514 proto tcp

With firewalld, a zone for the log sources:

sudo firewall-cmd --permanent --new-zone=logsources
sudo firewall-cmd --permanent --zone=logsources --add-source=10.20.0.0/16
sudo firewall-cmd --permanent --zone=logsources --add-port=514/udp --add-port=514/tcp --add-port=6514/tcp
sudo firewall-cmd --reload

With nftables, into an existing inet filter table (use insert instead of add if the chain ends in an explicit drop rule, and save the ruleset so it survives a reboot):

sudo nft add rule inet filter input ip saddr 10.20.0.0/16 udp dport 514 accept
sudo nft add rule inet filter input ip saddr 10.20.0.0/16 tcp dport '{ 514, 6514 }' accept
sudo nft add rule inet filter input ip saddr 203.0.113.0/24 tcp dport 6514 accept

Permit the same flows on router ACLs between device subnets and the collector, and never expose UDP 514 to the internet. If rsyslog fails to bind with a permission error on an SELinux system, the port lacks a syslog label: list labeled ports with semanage port -l | grep syslog and add yours, for example semanage port -a -t syslogd_port_t -p tcp 10514. The SNMP ports guide applies the same patterns to polling and traps.

Testing each port

# UDP 514
logger -n logs.example.net -P 514 -d "udp test from $(hostname)"
# TCP 514 with line-feed framing, then with octet counting
logger -n logs.example.net -P 514 -T "tcp test from $(hostname)"
logger -n logs.example.net -P 514 -T --octet-count "tcp octet test from $(hostname)"
# TLS 6514: does the handshake succeed with this client certificate?
openssl s_client -connect logs.example.net:6514 -CAfile ca.pem \
  -cert web01.example.net.crt -key web01.example.net.key </dev/null
# On the server: what actually arrives on the plain ports
sudo tcpdump -ni any -A 'port 514'

If the handshake works but nothing is logged, check framing first, then compare permittedPeer with the name in the client certificate.

The port checklist

  • UDP 514 only on management networks, for devices that cannot do better.
  • TCP 514 only where both ends agree on framing, and octet counting wherever the receiver supports it.
  • TLS on 6514 with client certificates for anything crossing a WAN or the internet.
  • A disk-assisted queue on every forwarding client.
  • max-connections() raised on syslog-ng TCP sources.
  • Firewall rules by source network, proven with logger and openssl s_client.
  • Next step: turn the lines that matter into events, as the field manual's syslog-to-events guide shows.

next: SNMP counter to bit rate for the numbers, the Rack list for the gear