All Projects → jamesmacwhite → ipset-netgear-r7000-dd-wrt

jamesmacwhite / ipset-netgear-r7000-dd-wrt

Licence: other
Packages and kernel modules for ipset support for the Netgear R7000 running DD-WRT firmware

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to ipset-netgear-r7000-dd-wrt

Glider
glider is a forward proxy with multiple protocols support, and also a dns/dhcp server with ipset management features(like dnsmasq).
Stars: ✭ 1,710 (+3700%)
Mutual labels:  dnsmasq, ipset
Config
Various program configuration files and scripts
Stars: ✭ 173 (+284.44%)
Mutual labels:  iptables, dnsmasq
Asuswrt Merlin Transparent Proxy
transparent proxy base on ss, v2ray, ipset, iptables, chinadns on asuswrt merlin.
Stars: ✭ 367 (+715.56%)
Mutual labels:  iptables, dnsmasq
go-ipset
🔥 Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility
Stars: ✭ 110 (+144.44%)
Mutual labels:  iptables, ipset
Piadvanced
This started as a custom install for my pihole!
Stars: ✭ 144 (+220%)
Mutual labels:  iptables, dnsmasq
blackip
IP Blocklist for Ipset / Squid-Cache
Stars: ✭ 81 (+80%)
Mutual labels:  iptables, ipset
kikpad
KiKPad : the Midiplus SmartPad reinvented !
Stars: ✭ 31 (-31.11%)
Mutual labels:  firmware
TinyCore
TinyCore boards / attiny 1 series Core, Arduino IDE Core, targets ATtiny 417 / 814 / 816 / 817 / 1614 / 1616 / 1617 / 3217 and similar MCUs
Stars: ✭ 31 (-31.11%)
Mutual labels:  firmware
ADios
ADBlocker - Block ADS on Twitch, Spotify and EVERYWHERE via the HOST File, PI-Hole, Adblocker Add-on, DNSMasq, Response Policy Zone and Adguard Services. - ADios ADS !
Stars: ✭ 73 (+62.22%)
Mutual labels:  dnsmasq
WIZ750SR
WIZnet Serial to Ethernet(S2E) module based on W7500 chip, WIZ107/108SR S2E compatible device
Stars: ✭ 13 (-71.11%)
Mutual labels:  firmware
fuzzware
Fuzzware's main repository. Start here to install.
Stars: ✭ 132 (+193.33%)
Mutual labels:  firmware
voron-ht
Klipper configuration for my Voron 2.4
Stars: ✭ 20 (-55.56%)
Mutual labels:  firmware
linksys-wrt54g
Exploiting Linksys WRT54G using a vulnerability I found.
Stars: ✭ 31 (-31.11%)
Mutual labels:  firmware
FlySkyRxFirmwareRssiMod
Patched firmwares for the various FlySky receivers to inject RSSI in IBUS channel 14
Stars: ✭ 96 (+113.33%)
Mutual labels:  firmware
sympetrum-v2
A communicative piece of wearable electronics.
Stars: ✭ 22 (-51.11%)
Mutual labels:  firmware
Linux-System-Management-Scripts-Tricks
Linux Security & Linux Hardening & Linux Management & Linux Configuration
Stars: ✭ 70 (+55.56%)
Mutual labels:  iptables
flipperzero-firmware
Flipper Zero firmware source code
Stars: ✭ 2,551 (+5568.89%)
Mutual labels:  firmware
nDPI
Open Source Deep Packet Inspection Software Toolkit
Stars: ✭ 92 (+104.44%)
Mutual labels:  iptables
prk firmware
A keyboard firmware platform in PicoRuby
Stars: ✭ 337 (+648.89%)
Mutual labels:  firmware
nsec-badge
Software from the NorthSec badge
Stars: ✭ 34 (-24.44%)
Mutual labels:  firmware

ipset support for the Netgear R7000 running DD-WRT

Additional packages and kernel modules for ipset support.

Introduction

ipset support is a somewhat challenging on DD-WRT because several key components for it are not currently built into the firmware. While DD-WRT can be extended by compiling additional userland tools and rolling your own firmware builds with the DD-WRT toolchain, this is a rather complex and overkill approach for adding additional features like ipset. This repository is a collection of additional ipk packages and kernel modules for ipset support on DD-WRT all in one place.

Note: These packages and modules are provided as is with no warranty/support. They have been tested on a R7000 (used in my own network) running DD-WRT firmware, other router models may vary.

Project directory structure

This explains what each directory is for and its purpose is related to ipset support.

ipk directory

The additional packages are mostly taken from the Entware project compiled with a compatible ARM toolchain that works on DD-WRT as well. You will need several additional packages for complete ipset. They are:

  • ipset (version 6) - Compiled with the matching DD-WRT kernel source tree
  • dnsmasq-full - To replace the version of dnsmasq built into DD-WRT in order to use ipset=/ policies (compiled with ipset support)
  • iptables - A newer version of iptables to use commands like --match-set

Here are the compile time options for dnsmasq I build with (version will vary, noted in the ipk filename):

Note: Due to several security vulnerabilities found with dnsmasq version < 2.78. It is recommended you only use dnsmasq version 2.78 or later.

While DD-WRT comes with both dnsmasq and iptables already, the dnsmasq version is compiled without ipset support, in addition the iptables version is v1.3.7 which is too old for some ipset based firewall rules.

These packages can be installed with the opkg command.

Example:

opkg install /path/to/package.ipk

In some cases you may also need to use the --force-checksum flag.

xt_set.ko kernel module

In order for iptables to work with ipset the xt_set.ko kernel module is needed. This is not present in any DD-WRT build currently. This is compiled using the DD-WRT kernel sources and matches the latest firmware kernel branch of the R7000 (currently linux-4.4).

Getting the right kernel source and toolchain is important when building modules, otherwise when attempting to load them you may kernel panic and crash your router. Likewise, you cannot simply use a module compiled on the 3.10 kernel compared to the 4.4 kernel and vice versa, you'll also likely crash your router upon attempting to load the module. This project includes the required kernel for both linux-3.10 and linux-4.4 builds. However, it is strongly recommended to use a recent build under the 4.4 kernel branch.

opt directory

If you don't have opkg installed, you can alternatively copy the entire contents of the /opt directory to your routers JFFS partition or a seperate mounted USB device. You will need to make sure you place the contents that matches the DD-WRT $PATH variable. Typically, this is what the DD-WRT path variable looks like:

/bin:/usr/bin:/sbin:/usr/sbin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin

This however is not recommended unless you know what you are doing, you'll also need to make sure you copy over the /opt folder preserving symlinks and permissions. 99.9% of users should install via the .ipk packages provided, its a lot easier! If however you want to cherry pick the binaries, this is possible.

Adding ipset support to DD-WRT

For dnsmasq and iptables you can overwrite the built in versions using a mount.

mount -o bind /opt/usr/sbin/dnsmasq /usr/sbin/dnsmasq
mount -o bind /opt/usr/sbin/iptables /usr/sbin/iptables
mount -o bind /opt/usr/sbin/ip6tables /usr/sbin/ip6tables

This will essentially redirect any call to the original firmware versions to the specially compiled ones. It provides a simple way of making sure your router uses the correct binaries. This can however cause problems as the firmware was not originally built with these versions.

Alternatively, if you are using Entware already, you can actually take advantage of running dnsmasq via the init.d script included: at /opt/etc/init.d/S56dnsmasq

Change ARGS to match the arguments used by DD-WRT:

-u root -g root --conf-file=/tmp/dnsmasq.conf --cache-size=1500

This allows you to essentially use the dnsmasq binary with ipset support while using the DD-WRT firmware dnsmasq.conf file allowing you to still make changes to dnsmasq normally. Finally, you'll need to stop the DD-WRT dnsmasq server and start the Entware version. You'll want to put this in your .rc_startup.

stopservice dnsmasq
/opt/etc/init.d/S56dnsmasq start

For iptables you can place additional rules within the usual .rc_firewall but ensure you reference to the full path to the newer iptables binary e.g. /opt/sbin/iptables

The kernel module for xt_set.ko can be placed within /jffs/usr/lib/modules and be loaded at boot time, using insmod:

insmod /jffs/usr/lib/modules/4.4/xt_set.ko

If everything was successful, you will get no prompt returned, running the same command again should yield something similar to:

insmod: cannot insert '/jffs/usr/lib/modules/4.4/xt_set.ko': File exists

This means the module is now loaded. You can also confirm this by running lsmod | grep "xt_set".

Ensure to change the kernel version in the insmod command to whatever kernel source it was built from as stated in the repo. The kernel module is versioned by kernel source because its important to keep track of what Linux kernel base source its come from. You can mostly get away with using a kernel module that is from a slightly different sublevel, but in most cases not an entirely different kernel version altogether. It is recommended to compile any kernel module against the same kernel source and sublevel relative to your firmware build to avoid instability.

JFFS storage is better for kernel modules as its a storage partition available early in the boot process. Alternatively you can also use /opt but you may have to delay executing code related to this module till a bit later on in the boot process, to ensure the USB device holding the /opt mountpoint is available.

Sometimes its also good to insmod custom kernel modules manually first, rather than adding insmod commands straight into to your .rc_startup. The reason being is if the module doesn't load properly and causes a kernel panic, you will essentially throw your router into a boot loop as it will keep trying to load the module causing the problem on startup.

Example tutorials using ipset

Once you've got ipset support setup on DD-WRT, you'll now want to start using it. Here's a few tutorials on what you can do. Common examples are country blocklists and selective VPN routing using domain based rules.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].