garycnew
Senior Member
ATTENTION: It has come to my attention that there is an established Asuswrt-Merlin Add-on in AMTM called scribe and a user interface for it called uiscribe that takes the native Asuswrt-Merlin Syslog implementation to the next level, which is the recommended approach over this tutorial.
The following is an Asuswrt-Merlin Remote Log Server (Syslog & Syslog-ng Synergy) to Centralize Primary Router & AiMesh Node System Logs Tutorial gleaned from Existing Posts in this Forum (RE: References), but taking a slightly different approach by making use of the existing Syslog process, Remote Logging to Syslog-ng, maintaining the existing Syslog (/tmp/syslog.log) location, and using iptables to Drop Duplicate Logging of Primary Router.
Requirements/Assumptions:
1. An Asuswrt-Merlin Compatible Router (i.e., Asus RT-AC66U)
2. Asuswrt-Merlin Compatible Firmware (i.e., 384.19)
3. Formated JFFS Partition and Enabled JFFS Custom Scripts and Configs
4. Capable of Modifying NVRAM Settings
5. Capable of Editing the following User Scripts:
/jffs/configs/firewall-start
### Primary Router: Update/Install Entware Syslog-ng ###
### (Optional) Remove Syslog-ng & Dependencies ###
### Primary Router: Edit syslog-ng.conf to Change file() Location & Uncomment source() to Open Port 514 ###
### Primary Router: Start Syslog-ng ###
### Primary Router: Verify Syslog-ng is Listening on the Any Address (0.0.0.0) and UDP Port 514 ###
### Primary Router: Verify Syslog's Pre-WebUI Run-Time Configuration ###
### Primary Router: In the Asuswrt-Merlin WebUI under Advance Settings > System Log > General Log for Remote Log Server enter 192.168.0.1 (Private Gateway Address) and for Port enter 514 (Syslog-ng UDP Port) then Click "Apply" ###
### Primary Router: Verify Syslog's Post-WebUI Run-Time Configuration ###
### Primary Router: Add iptables Rule to Drop Duplicate Logging of Primary Router to Syslog-ng over UDP Port 514
### Primary Router: Create/Edit firewall-start Script to Persist Drop Duplicate Logging of Primary Router to Syslog-ng ###
### Primary Router: Section for Potential Implementation of Syslog Filters ###
### Primary Router: Section for Potential Implementation of Logrotate ###
### AiMesh Node: Verify NVRAM log_ Settings ###
### AiMesh Node: Change NVRAM log_level from 7=Debug to 6=Notice to be less Verbose ###
### AiMesh Node: Verify NVRAM lan_hostname Setting ###
### AiMesh Node: Change NVRAM lan_hostname to something more readable in the Syslogs ###
### AiMesh Node: Commit NVRAM Settings & Reboot ###
### AiMesh Node: Verify Syslog's Post-NVRAM Change Run-Time Configuration ###
### (Optional) Primary Router: Restart Syslog & Syslog-ng ###
### Primary Router: View the Centralized Primary Router & AiMesh Node System Logs from the Command-Line or Asuswrt-Merlin WebUI ###
Congratulations! You have a successfully working Asuswrt-Merlin Remote Log Server (Syslog & Syslog-ng Synergy) to Centralize Primary Router & AiMesh Node System Logs.
A BIG "Thank You" to those who Pioneered this Solution (RE: References).
Referernces:
The following is an Asuswrt-Merlin Remote Log Server (Syslog & Syslog-ng Synergy) to Centralize Primary Router & AiMesh Node System Logs Tutorial gleaned from Existing Posts in this Forum (RE: References), but taking a slightly different approach by making use of the existing Syslog process, Remote Logging to Syslog-ng, maintaining the existing Syslog (/tmp/syslog.log) location, and using iptables to Drop Duplicate Logging of Primary Router.
Requirements/Assumptions:
1. An Asuswrt-Merlin Compatible Router (i.e., Asus RT-AC66U)
2. Asuswrt-Merlin Compatible Firmware (i.e., 384.19)
3. Formated JFFS Partition and Enabled JFFS Custom Scripts and Configs
4. Capable of Modifying NVRAM Settings
5. Capable of Editing the following User Scripts:
/jffs/configs/firewall-start
### Primary Router: Update/Install Entware Syslog-ng ###
Code:
# ssh admin@192.168.0.1
# opkg update
# opkg install syslog-ng
Installing syslog-ng (3.32.1-1) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/syslog-ng_3.32.1-1_armv7-2.6.ipk
Installing libiconv-full (1.16-1) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libiconv-full_1.16-1_armv7-2.6.ipk
Installing libintl-full (0.21-2) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libintl-full_0.21-2_armv7-2.6.ipk
Installing libattr (2.5.1-3) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libattr_2.5.1-3_armv7-2.6.ipk
Installing glib2 (2.68.1-3) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/glib2_2.68.1-3_armv7-2.6.ipk
Installing libdbi (0.9.0-5) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libdbi_0.9.0-5_armv7-2.6.ipk
Installing libjson-c (0.15-2) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libjson-c_0.15-2_armv7-2.6.ipk
Installing libcurl (7.77.0-1) to root...
Downloading http://bin.entware.net/armv7sf-k2.6/libcurl_7.77.0-1_armv7-2.6.ipk
Configuring libiconv-full.
Configuring libintl-full.
Configuring libattr.
Configuring glib2.
Configuring libdbi.
Configuring libjson-c.
Configuring libcurl.
Configuring syslog-ng.
### (Optional) Remove Syslog-ng & Dependencies ###
Code:
# opkg remove syslog-ng glib2 libiconv-full libintl-full libattr libdbi libjson-c libcurl
# opkg remove logrotate libpopt
### Primary Router: Edit syslog-ng.conf to Change file() Location & Uncomment source() to Open Port 514 ###
Code:
# vi /opt/etc/syslog-ng.conf
…
#file("/opt/var/log/messages");
file("/tmp/syslog.log");
…
# uncomment this line to open port 514 to receive messages
source(s_network);
### Primary Router: Start Syslog-ng ###
Code:
# /opt/etc/init.d/S01syslog-ng start
Starting syslog-ng... done.
### Primary Router: Verify Syslog-ng is Listening on the Any Address (0.0.0.0) and UDP Port 514 ###
Code:
# netstat -anp | grep syslog-ng
tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 2064/syslog-ng
tcp 0 0 0.0.0.0:6514 0.0.0.0:* LISTEN 2064/syslog-ng
tcp 0 0 0.0.0.0:601 0.0.0.0:* LISTEN 2064/syslog-ng
udp 0 0 0.0.0.0:514 0.0.0.0:* 2064/syslog-ng
udp 0 0 127.0.0.1:514 0.0.0.0:* 2064/syslog-ng
### Primary Router: Verify Syslog's Pre-WebUI Run-Time Configuration ###
Code:
# ps w | grep -i syslog
32650 admin 1416 S /sbin/syslogd -m 0 -S -O /tmp/syslog.log -s 256 -l 6
### Primary Router: In the Asuswrt-Merlin WebUI under Advance Settings > System Log > General Log for Remote Log Server enter 192.168.0.1 (Private Gateway Address) and for Port enter 514 (Syslog-ng UDP Port) then Click "Apply" ###
### Primary Router: Verify Syslog's Post-WebUI Run-Time Configuration ###
Code:
# ps w | grep -i syslog
110 admin 1424 S /sbin/syslogd -m 0 -S -O /tmp/syslog.log -s 256 -l 6 -R 192.168.0.1:514 -L -H gnutech-wap01-CA04B43-C
2062 admin 8540 S {syslog-ng} supervising syslog-ng
2064 admin 22936 S syslog-ng
### Primary Router: Add iptables Rule to Drop Duplicate Logging of Primary Router to Syslog-ng over UDP Port 514
Code:
# iptables -I INPUT -i lo -p udp -s 192.168.0.1 --dport 514 -j DROP
### Primary Router: Create/Edit firewall-start Script to Persist Drop Duplicate Logging of Primary Router to Syslog-ng ###
Code:
# touch /jffs/scripts/firewall-start
# chmod 755 /jffs/scripts/firewall-start
# vi /jffs/configs/firewall-start
#!/bin/sh
sleep 10 # During the boot process firewall-start may run multiple times so this is required
# Drop Duplicate Logging of Primary Router to Syslog-ng over UDP Port 514
# iptables -I INPUT -i lo -p udp -s 192.168.0.1 --dport 514 -j DROP
### Primary Router: Section for Potential Implementation of Syslog Filters ###
### Primary Router: Section for Potential Implementation of Logrotate ###
### AiMesh Node: Verify NVRAM log_ Settings ###
Code:
# ssh admin@192.168.0.11
# nvram show | grep -i "^log_"
log_ipaddr=192.168.0.1
log_port=514
log_size=256
log_level=7
log_path=/jffs
### AiMesh Node: Change NVRAM log_level from 7=Debug to 6=Notice to be less Verbose ###
Code:
# nvram set log_level=6
### AiMesh Node: Verify NVRAM lan_hostname Setting ###
Code:
# nvram show | grep -i lan_hostname
lan_hostname=RT-AC66U_B1-3C73
### AiMesh Node: Change NVRAM lan_hostname to something more readable in the Syslogs ###
Code:
nvram set lan_hostname=Office-3C73
### AiMesh Node: Commit NVRAM Settings & Reboot ###
Code:
# nvram commit
# reboot
### AiMesh Node: Verify Syslog's Post-NVRAM Change Run-Time Configuration ###
Code:
# ssh admin@192.168.0.11
# ps w | grep -i syslog
5286 admin 1424 S /sbin/syslogd -m 0 -S -O /tmp/syslog.log -s 256 -l 6 -R 192.168.0.11:514 -L -H Office-3C73-CA04B43-R
### (Optional) Primary Router: Restart Syslog & Syslog-ng ###
Code:
# ssh admin@192.168.0.1
# service restart_logger
Done.
# /opt/etc/init.d/S01syslog-ng reconfigure
Sending SIGHUP to syslog-ng...
### Primary Router: View the Centralized Primary Router & AiMesh Node System Logs from the Command-Line or Asuswrt-Merlin WebUI ###
Code:
# ssh admin@192.168.0.1
# tail -f /tmp/syslog.log
Aug 21 23:20:44 syslog: WLCEVENTD wlceventd_proc_event(500): eth2: Auth F8:38:80:A9:F1:A9, status: Successful (0)
Aug 21 23:20:44 syslog: WLCEVENTD wlceventd_proc_event(529): eth2: Assoc F8:38:80:A9:F1:A9, status: Successful (0)
Aug 21 23:22:03 gnutech-wap01 rc_service: service 22892:notify_rc restart_logger
Aug 21 23:22:04 kernel: klogd started: BusyBox v1.25.1 (2020-08-14 15:17:43 EDT)
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: Accepting connections; addr='AF_INET(0.0.0.0:514)'
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: You have a TLS enabled source without a X.509 keypair. Make sure you have tls(key-file() and cert-file()) options, TLS handshake to this source will fail; location='/opt/etc/syslog-ng.conf:33:2'
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: Accepting connections; addr='AF_INET(0.0.0.0:6514)'
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: Accepting connections; addr='AF_INET(0.0.0.0:601)'
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: Configuration reload request received, reloading configuration;
Aug 22 05:22:15 gnutech-wap01 syslog-ng[14682]: Configuration reload finished;
Aug 21 23:22:56 dropbear[23028]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63523
Aug 21 23:23:09 Living_Room-C293-CA04B43-R dropbear[2965]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63524
Aug 21 23:23:14 Data_Center-D448-CA04B43-R dropbear[22487]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63525
Aug 21 23:23:17 Office-3C73-CA04B43-R dropbear[22037]: Child connection from 192.168.0.232:63526
Aug 21 23:23:18 Office-3C73-CA04B43-R dropbear[22037]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63526
Aug 21 23:23:21 Garage-AE61-CA04B43-R dropbear[14223]: Child connection from 192.168.0.232:63527
Aug 21 23:23:22 Garage-AE61-CA04B43-R dropbear[14223]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63527
Aug 21 23:23:25 Wiring_Closet-5610-CA04B43-R dropbear[6917]: Child connection from 192.168.0.232:63528
Aug 21 23:23:25 Wiring_Closet-5610-CA04B43-R dropbear[6917]: Pubkey auth succeeded for 'admin' with key sha1!! 12:2f:2c:eb:8d:9a:89:c7:ed:7d:08:e8:cf:ab:94:75:db:b7:76:be from 192.168.0.232:63528
Congratulations! You have a successfully working Asuswrt-Merlin Remote Log Server (Syslog & Syslog-ng Synergy) to Centralize Primary Router & AiMesh Node System Logs.
A BIG "Thank You" to those who Pioneered this Solution (RE: References).
Referernces:
Code:
https://www.snbforums.com/threads/configuring-syslog-ng-with-merlin-firmware.35095/
Last edited: