Compiling ipset via Entware
Entware-ng is setup for cross-compiling various packages, so I've tended to borrow from it for adding additional packages for DD-WRT, rather than having to setup my own cross-compiling setup. I know lazy. Alternatively you can download the source of ipset from: http://ipset.netfilter.org/install.html and cross-compile it yourself.
If you haven't already got the Entware-ng build environment, you should follow this guide first:
https://github.com/Entware-ng/Entware-ng/wiki
For newer routers which uses newer kernels such as 3.x or 4.x, you can also use the "Entware for kernel 3.x" project, which is a fork of Entware-ng designed for newer routers. The configuration and compiling instructions are the same.
https://github.com/Entware-for-kernel-3x/Entware-ng-3x
Before running the compile command for building ipset, you'll want to make a couple of changes.
Edit your .config
and change CONFIG_PACKAGE_ipset
:
CONFIG_PACKAGE_ipset=y
This will build ipset as a .ipk package for easy installation.
In addition, for absolute compatibility, you should also edit the package/network/utils/ipset/Makefile
and change --with-kbuild
to the DD-WRT kernel source directory based on same sources you are using for the xt_set.ko
module, rather than using the Linux build directory within Entware-ng.
Here's a small script that will do this for you. Modify the paths and values according to your requirements:
#!/bin/bash
# Entware-ng source paths
ENTWARE_NG_SOURCE_DIR="/root/Entware-ng" # Change to the root of where the Entware-ng source tree is
ENTWARE_NG_IPSET_MAKEFILE="${ENTWARE_NG_SOURCE_DIR}/package/network/utils/ipset/Makefile"
# DD-WRT source paths
DD_WRT_SOURCE_DIR="/root/dd-wrt" # Change to the root of where the DD-WRT source tree is
DD_WRT_KERNEL_TARGET="linux-4.4" # Change if you need to use kernel 3.10
DD_WRT_KERNEL_SOURCE_DIR="${DD_WRT_SOURCE_DIR}/src/linux/universal/${DD_WRT_KERNEL_TARGET}"
echo 'Replacing $(LINUX_DIR) with absolute path to DD-WRT kernel source dir"
sed -i "s@\$(LINUX_DIR)@${DD_WRT_KERNEL_SOURCE_DIR}@" "${ENTWARE_NG_IPSET_MAKEFILE}"
Essentially this just replaces the $(LINUX_DIR)
value in the ipset Makefile via sed
.
Finally, you can then compile ipset as normal.
make package/ipset/compile
Once successful, you should have an ipk available at:
./bin/targets/armv7soft/generic-glibc/packages
You can upload this to your router and install it with opkg
.