@Adamm,
Would it be good idea to have an option that uses a timeout on the blocked addresses so the list doesn't grow too big ?
I doubt seriously someone would be foolish enough to continually use the same IP address.
@Martineau or @Adamm planning on maintaining that script ? cause if you are i could add it to the wiki
If you are concerned on access on specific ports that are NOT open, the built in FW will already block that. So I am still not very clear as to the benefit as the script is harvesting IPs that are already being dropped.
Yes and Yes! See this wiki for more info on ipset...Are those scripts strictly for the rt-68?
Can they work on an rt-3100?
UPDATED 12/04/2017
Currently this script is only supported for ARM based routers (AC56U/AC68U) as they run a different version of IPTables
Below you will find a script that automates the process of banning/whitelisting IP's you desire. The main reason for this script was to automaticly and permanently ban IP's that show up in the routers syslog under the prefix "DROP *".
In simple terms what this script does is add a few extra IPTables rules so rather then just rejecting the request and letting it continue to portscan etc, the malicious IP in question will be forwarded to an IPSet also created by this script. IPSet is a kernel module that efficiently can block hundreds of thousands of IP's without any performance degreadion.
INSTALLATION;
Part 1
Part 2
Rember to "chmod +x" files after creating them so they can be executed.
To confirm this has worked, reboot your router and you should see "Firewall: [IP Banning Started] ... ... ..." present at the bottom of your routers syslog.
USAGE;
Usage of this script is fairly straight forward and each function is separated and described in the file provided. Each command can be executed from SSH using the syntax "firewall *commandhere*"
WHITELISTING;
By default, 192.168.1.0/24 & the value of "nvram get lan_ipaddr"/24 will be whitelisted to prevent accidentally locking yourself out from the routers GUI. Please note if you wish to whitelist other IP's the script currently is defaulted to only accept blocks of /24 from a specified file location when using the "firewall whitelist" command.
OTHER FUNCTIONS;
Other features of this script include being able to ban IP ranges of entire countries which is useful to ban countries with lots of malicious spam IP's. Using the "firewall country" command you can specify specific countries by inputting their two letter abbreviation and by using the "firewall bancountry" command you will ban the pre-determined countries from personal experience (pk cn in jp ru sa)
I am open to any suggestions for modifying this script as this version is specifically for the community as there have been lots of requests for this type of functionality. Please note this script will only work on RMerlin based firmwares with JFFS enabled. Hope others can put it to good use
I tried the above command at ssh prompt.....firewall whitelist and it fails says firewall: not found . Can you help me please?
Edit: I tried using the command ipset list Blacklist and it works gives me a big list of IP's is this verification that the script is running?
cd /jffs/scripts
./firewall *command*
You need to be in the current directory for it to execute, if you have entware installed you can make a symlink from the bin folder so it can be executed from anywhere
The syslog in the router GUI should also give you hourly updates on how many IP's are banned (and freshly banned)
sh /jffs/scripts/firewall save
"unban" # <-- Remove Single IP From Blacklist
"unbanall" # <-- Unbans All IPs In Blacklist
"removeall" # <-- Remove All Entries From Blacklist
"save" # <-- Save Blacklists to /jffs/scripts/ipset.txt
"ban" # <-- Adds Entry To Blacklist
"country" # <-- Adds entire country to blacklist
"bancountry" # <-- Bans specified countries in this file
"banmalware" # <-- Bans various malware domains
"whitelist" # <-- Add IPs from path to Whitelist
"new" # <-- Create new IPSet Blacklist
Apr 15 18:00:02 Firewall: [Complete] 22798 IPs currently banned. 50 New IP's Banned. 22797 Banned Overall [2s]
Please copy the exact output.
EDIT;
That's just lsmod trying to load a kernel module that's already loaded. You can ignore that error, ill silence it in future.
Running the script by its-self wont prompt you for input, you have to specify the command when executing. For example..
Code:sh /jffs/scripts/firewall save
Also, the hourly update in your log should look like the following (if you setup the "/jffs/scripts/firewall-start" script as shown)
That output is perfectly normal and the script is running as it should, what are you trying todo specifically?
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!