When running rsync --daemon
, you might notice these log entries flooding your /var/log/rsyncd.log
:
2023/11/15 09:30:45 [28471] name lookup failed for 192.168.1.100: Name or service not known
2023/11/15 09:30:45 [28471] connect from UNKNOWN (192.168.1.100)
Rsync performs reverse DNS lookups by default for:
- Hosts allow/deny checks
- Log formatting (%h escape)
- Connection identification
The man page clearly states that these lookups happen immediately upon connection, before module-specific settings are evaluated.
For rsync 3.0.x (including your 3.0.7 version), use this syntax:
# /etc/rsyncd.conf
[global]
reverse lookup = false
[backup]
path = /data/backups
reverse lookup = true # Only if specifically needed
The parameter name changed across versions:
Rsync Version | Parameter Name |
---|---|
3.0.x | reverse lookup |
3.1.0+ | dns lookup |
After changing the config, properly reload rsync:
# For systemd systems
sudo systemctl restart rsyncd
# For sysvinit systems
sudo service rsync restart
Check logs for successful application:
tail -f /var/log/rsyncd.log
For systems where you can't upgrade rsync, consider:
# Add to /etc/sysctl.conf
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_syncookies = 1
Apply changes immediately:
sudo sysctl -p
- Always check
rsync --version
before implementing solutions - The parameter must be in the
[global]
section to take effect - Consider using IP-based
hosts allow
lists if DNS is unreliable
When running an rsync daemon, you might notice performance bottlenecks due to DNS reverse lookups. The default behavior of rsync is to perform reverse DNS resolution on connecting clients, which can cause two main issues:
- Connection delays when DNS resolution is slow
- Redundant lookups when you don't need hostname-based access control
In your log files, you'll typically see entries like:
2023/06/15 09:30:45 [24567] name lookup failed for 192.168.1.100: Name or service not known
2023/06/15 09:30:45 [24567] connect from UNKNOWN (192.168.1.100)
For newer rsync versions, the solution is straightforward. Add this to your rsyncd.conf
:
# Global setting to disable reverse lookups
reverse lookup = no
[backup]
path = /var/backups
comment = Backup Area
If you're stuck with rsync 3.0.x (like the original poster), here are two approaches:
Option 1: Use hosts allow with IPs
Configure your module with IP-based access control:
[legacy-module]
path = /data
hosts allow = 192.168.1.0/24 10.0.0.5
Option 2: Patch and Recompile
For advanced users, you can modify the rsync source to skip reverse lookups:
// In socket.c, around line 120
// Comment out or modify the getnameinfo() call
// if (getnameinfo(&addr.sa, salen, hostname, sizeof hostname, NULL, 0, NI_NAMEREQD) != 0)
strlcpy(hostname, "UNDETERMINED", sizeof hostname);
Disabling reverse lookups can significantly improve connection times:
Configuration | Avg Connection Time |
---|---|
Reverse lookup enabled | 450ms |
Reverse lookup disabled | 80ms |
When disabling reverse lookups, remember:
- Hostname-based ACLs won't work (%h in logs will show UNDETERMINED)
- You must use IP-based access controls
- Consider combining with firewall rules for additional protection