Detect IPv6 packets via CRON / script issue.

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
dpp3530
DD-WRT Guru


Joined: 12 Dec 2007
Posts: 547
Location: Pittsburgh, PA USA

PostPosted: Mon Oct 04, 2021 20:42    Post subject: Detect IPv6 packets via CRON / script issue. Reply with quote
I have Verizon as my ISP, and they have not yet rolled out IPV6 to all locations. While reading the DSLReports.com forums on Verizon and IPV6, I found a script that someone wrote for PFSense that uses TCPDump to listen for IPV6 RA packets, thereby letting you know when IPV6 gets turned up in your area. After installing a few things in Entware (coreutils-timeout, mstmp, and busybox), I was able to adapt the script to run under DD-WRT r47225 (and subsequent releses). It's installed on a USB thumbdrive partition mounted as /jffs. I should add that this is on a WRT1900AC v1.

The script is intended to run once per day and listen for 5 minutes, then if a packet is detected, send an email notifying me. It also logs the start and end of the script in the system log. I have syslogd and klogd enabled.

If I run the script from the command line (SSH), it listens for 5 minutes and the two log entries are exactly 5 minutes apart. If I run it from a cron job, the end entry immediately follows the start entry, meaning it didn't listen for any time at all. I thought the difference in behavior had to do with it not running under root access, but I think I've ruled that out. The script is supposed to run at 5:01AM.

Currently my cron entry is:
1 5 * * * root sh /jffs/v6test.sh

But I've also tried
1 5 * * * sh /jffs/v6test.sh
1 5 * * * root /jffs/v6test.sh

I'm hoping someone can help me figure out what I'm doing wrong. I have searched the forums, the wiki, and anything else on Google related to Cron jobs.

The code for the script is below (email address redacted):

Code:
#!/bin/sh

# set the variable below to your FIOS interface
IF=eth1
logger -t v6test "Starting daily scan for IPV6"
timeout 300 tcpdump -ni ${IF} 'icmp6 && ip6[40] == 134' -c 10 >/tmp/${IF}_RAs.out
FSIZE=$(stat /tmp/${IF}_RAs.out)
FSIZE2=$(echo $FSIZE | cut -c33-34)
echo $FSIZE2
if [ "$FSIZE2" -gt 1 ]; then
  logger -t v6test "RA packet detected on eth1 $0"
  cat /jffs/mail.txt | msmtp -a gmail redacted@mydomain.com
fi
logger -t v6test "End scan for IPV6"

_________________
__________________________
Linksys WRT-1900AC
DD-WRT v3.0 STD 47618
Linksys EA6700
DD-WRT v3.0 STD 47618
Asus RT-AC56U
DD-WRT v3.0 STD 47618
Netgear AC1450
DD-WRT v3.0 STD 47618
Sponsor
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 4
Location: FL

PostPosted: Sun Nov 21, 2021 3:48    Post subject: Reply with quote
Quote:
I was able to adapt the script to run under DD-WRT r47225

Have you tried a different build?

I've read here some builds may have broken cron.

_________________
DD-WRT v3.0-r47656 std (11/18/21) on WRT3200ACM and flying...
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 11210
Location: Texas, USA

PostPosted: Sun Nov 21, 2021 4:08    Post subject: Reply with quote
Ostddwrt wrote:
Quote:
I was able to adapt the script to run under DD-WRT r47225

Have you tried a different build?

I've read here some builds may have broken cron.

Quote:
Running on build 41586 (11/21/19) on a wrt1900acsv2

Interjection of irrelevant information as cron was fixed already.

https://svn.dd-wrt.com/ticket/6916

https://svn.dd-wrt.com/changeset/41702

https://svn.dd-wrt.com/changeset/41189

https://svn.dd-wrt.com/ticket/6824

https://svn.dd-wrt.com/ticket/6744

There is *this* ticket, that doesn't seem like it was ever followed up on, though:

https://svn.dd-wrt.com/ticket/6688

CRON DD-WRT Wiki: https://forum.dd-wrt.com/wiki/index.php/CRON

_________________
Official Forum Rules, Guidelines & Helpful InformationFirmware FAQInstallation WikiWhere Do I Download Firmware‽
DON'T use Chromium-based browsersRTFM/STFW TL;DR is NOT an excuse. • Why Should I Care What Color the Bikeshed Is‽
Please DO NOT PM me with questions; Ask in the forum. ---------------------- Linux User #377467 counter.li.org / linuxcounter.net
dpp3530
DD-WRT Guru


Joined: 12 Dec 2007
Posts: 547
Location: Pittsburgh, PA USA

PostPosted: Sun Nov 21, 2021 14:37    Post subject: Reply with quote
Ostddwrt wrote:
Quote:
I was able to adapt the script to run under DD-WRT r47225

Have you tried a different build?

I've read here some builds may have broken cron.


I've tried most of the newer builds since 47225. I'm on 47656 right now and it's still happening

Code:
root@Barricade:/tmp/var/log# cat messages | grep v6test
Nov 21 09:19:00 Barricade user.notice v6test: Starting daily scan for IPV6
Nov 21 09:19:00 Barricade user.notice v6test: End scan for IPV6
Nov 21 09:20:32 Barricade user.notice v6test: Starting daily scan for IPV6
Nov 21 09:25:32 Barricade user.notice v6test: End scan for IPV6


The first two are from the CRON job, where the last two lines are a manual run.

Timeout is running of a USB stick. One of those links seemed to indicate that might be related.

_________________
__________________________
Linksys WRT-1900AC
DD-WRT v3.0 STD 47618
Linksys EA6700
DD-WRT v3.0 STD 47618
Asus RT-AC56U
DD-WRT v3.0 STD 47618
Netgear AC1450
DD-WRT v3.0 STD 47618
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum