r/linuxadmin • u/ReDiculum0 • Mar 25 '26
Problem rsyslog to elastic over Wireguard and iptables
Hello, can anybody explain why rsyslog is not able to pass iptables to the remote ES (10.0.72.20) over VPN, but netcat (and telnet) does?
# nc -w1 -z 10.0.72.20 9200
#
# iptables -A OUTPUT -d 10.0.72.0/24 -j ACCEPT
# systemctl restart rsyslog
kernel: IPTABLES denied: IN= OUT=wg0 SRC=192.168.78.2 DST=10.0.72.20 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=11441 DF PROTO=TCP SPT=52994 DPT=9200 WINDOW=64860 RES=0x00 SYN URGP=0
# nc -z 10.0.72.20 9200
Connection to 10.0.72.20 9200 port [tcp/*] succeeded!
#
4
Upvotes
1
u/ReDiculum0 Mar 25 '26
UPDATE:
It's very strange, because I receive logs in Kibana from this host, even if iptables does drop. I have no idea
1
u/vivaaprimavera Mar 25 '26
Are you running those commands as root? Have you tested the connection with other users?
-5
u/t4lonius Mar 25 '26
Here's what Google (copy->paste) says (I would have scrolled on by, but the port 9200 and netcat triggered some recent Elastic Agent troubleshooting trauma):
This sequence shows a common troubleshooting scenario where an iptables firewall rule was blocking outgoing traffic to a database (likely Elasticsearch on port 9200), and was fixed by adding an explicit "ACCEPT" rule. [1, 2, 3]
Step-by-Step Breakdown
Initial Failure:
nc -w1 -z10.0.72.209200nc) attempts to scan (-z) the target IP10.0.72.20on port9200with a 1-second timeout (-w1).The Fix:
iptables -A OUTPUT -d10.0.72.0/24-j ACCEPT-A) a rule to the OUTPUT chain.10.0.72.0/24network (IPs from 10.0.72.1 to 10.0.72.254).Logging & Verification:
systemctl restart rsyslogEvidence of the Block:
kernel: IPTABLES denied: IN= OUT=wg0 SRC=192.168.78.2 DST=10.0.72.20 ... PROTO=TCP DPT=9200 ... SYNSYN) from your local IP (192.168.78.2) to the target (10.0.72.20) on port9200was rejected as it tried to exit via thewg0(WireGuard VPN) interface.Final Success:
nc -z10.0.72.209200Connection ... succeeded!2
u/[deleted] Mar 25 '26
[removed] — view removed comment