LinkSys EA6700 - building a script to manipulate iptables

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
mag16
DD-WRT Novice


Joined: 24 Mar 2014
Posts: 6

PostPosted: Sat Jan 08, 2022 9:25    Post subject: LinkSys EA6700 - building a script to manipulate iptables Reply with quote
Gents, can I find some help here regard the subject?

I have an EA6700 charged with v3.0-r41771. I intend to have the firewall filtering the clients by MAC addresses based on a schedule. So far I think of a script on a USB stick that would build cron jobs upon starting the router in the same way as I'm starting cron jobs now on via Administration->Management->Additional Cron Jobs.
Cron daemon must apply rules to iptables based on current time and day of week. At the same time, there must be a default instance of iptables rule set that would be active in case the router is started without USB stick.

As far as I know, the problem with 32kB of nvram is not solved in the build installed on my router, so I think that the script must be placed on a USB stick.

For the moment I have inserted a stick in the router. When I inserted it, in Services->USB I had the option to enable Core USB Support, USB Storage Support and Automatic Drive Mount. I followed a guide that tells to go to NAS section and format the drive from that page. Here begins the confuse.
In NAS section, in the bottom of the page, there is Drive Manager. I guessed that I have to put there Optware in label and format Ext2 and press Format button. But nothing happens. May it be because of a bug in the build, or because of that that the formatting here works only in case of enabling the Samba or FTPD? Either way it is confusing. So, I restarted the router. It took a little bit longer time to restart. When checked for the drive to be mounted in the /opt - it was not there. So, I formatted the drive from the command line with "mkfs.ext2 -L Optware -t ext2 /dev/sda1".

Finally the stick is there but I have a problem. When I restart the router, the stick is not mounted automatically unless I go to the Services->USB and press Save then Apply. After this the stick shows up in the Services->USB and Services->NAS as /dev/sda and /dev/sda1 formatted as ext4, and in WinSCP in the path /opt as folders that I have created before reboot. But if I run ls in the /opt folder, it doesn't show the content of the stick. Instead it returns a folder "lib" that seems to be there when the stick is not mounted. At the same time I have an empty folder Optware in the /tmp/mnt folder.

Can somebody help me mount the stick automatically in a reliable mode, so I can put a script to handle the cron jobs and iptables rules?

As a bonus question, how can I install Entware so I could install MC which I miss pretty much. Smile
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12837
Location: Netherlands

PostPosted: Sat Jan 08, 2022 9:41    Post subject: Reply with quote
You are running an old and unsupported build.

Consider upgrading to a recent build e.g. 47942

Attached my slightly outdated personal notes how I do it

To get the best out of DDWRT and the forum read the forum guidelines full of helpful pointers:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087

Note:
When running scripts from a USB stick make sure you add "sleep 30" or "is-mounted /opt" to wait for the USB stick being ready

Note 2:
I think your router has the time module so that you can make iptables rule with time.
Some documentation about this can be found in the IPSET documentation: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=327261



DDWRT USB storage support Public.doc
 Description:

Download
 Filename:  DDWRT USB storage support Public.doc
 Filesize:  396 KB
 Downloaded:  89 Time(s)


_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
mag16
DD-WRT Novice


Joined: 24 Mar 2014
Posts: 6

PostPosted: Sat Jan 08, 2022 12:29    Post subject: Reply with quote
egc wrote:
You are running an old and unsupported build.

Consider upgrading to a recent build e.g. 47942

So, you think that in most recent versions the USB is treated in a right way? Or this is just a "good advice"?
Quote:
Note:
When running scripts from a USB stick make sure you add "sleep 30" or "is-mounted /opt" to wait for the USB stick being ready

Thanks for the hint!
Quote:

Note 2:
I think your router has the time module so that you can make iptables rule with time.
Some documentation about this can be found in the IPSET documentation: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=327261


I will give it a chance.
Thank you very much for your reply.[/quote]
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12837
Location: Netherlands

PostPosted: Sat Jan 08, 2022 12:37    Post subject: Reply with quote
Your build is old, unsupported and has security issues.

So regardless of USB (which changed considerably) you are advised to update.

Coming from such an old build a full reset after updating and putting settings in manually is also advised (never restore settings from a different build!)

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
mag16
DD-WRT Novice


Joined: 24 Mar 2014
Posts: 6

PostPosted: Sun Jan 09, 2022 9:01    Post subject: Reply with quote
egc wrote:
Your build is old, unsupported and has security issues.
So regardless of USB (which changed considerably) you are advised to update.

Hi,

I have upgraded to the version you suggested with reset after install and manually entering all the settings.

At the beginning, I was able to mount my 16GB USB2.0 stick in the /opt folder. Then I had to change the admin password and all the things went wrong, so I had to reset the router to get access to it. After resetting the stick mounted only once, but after subsequent reboots it didn't mount at all. More of this, it doesn't appear neither in the /dev folder as sda1 nor sda.

Is there a trick that I've missed?
mag16
DD-WRT Novice


Joined: 24 Mar 2014
Posts: 6

PostPosted: Tue Jan 11, 2022 13:31    Post subject: Reply with quote
Gents,
Still wondering about USB support on the latest versions. Anybody?
kernel-panic69
DD-WRT Guru


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

PostPosted: Tue Jan 11, 2022 14:49    Post subject: Reply with quote
egc wrote:
Note:
When running scripts from a USB stick make sure you add "sleep 30" or "is-mounted /opt" to wait for the USB stick being ready

Why was the USB script option added to the webUI? I thought it was so this wasn't necessary...

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
mag16
DD-WRT Novice


Joined: 24 Mar 2014
Posts: 6

PostPosted: Wed Jan 12, 2022 10:40    Post subject: Reply with quote
kernel-panic69 wrote:
egc wrote:
Note:
When running scripts from a USB stick make sure you add "sleep 30" or "is-mounted /opt" to wait for the USB stick being ready

Why was the USB script option added to the webUI? I thought it was so this wasn't necessary...

Thanks for your implication. But, no, it's not about the script yet, but the USB stick, that doesn't get mounted. See, please my previous posts.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware 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 can attach files in this forum
You can download files in this forum