-
Notifications
You must be signed in to change notification settings - Fork 6
Compiling ipset from source
If you don't want to use Entware-ng, you can manually compile ipset and other packages yourself. This will however involve you having the knowledge of how to cross-compile.
Unlike Entware-ng, compiling via the source itself without any buildroot requires manual preparation. Instead you'll need to setup your toolchain and paths to various libs and such manually.
For DD-WRT you'll want to refer to the toolchains section of the kernel source guide, in order to setup the right environment.
To make things easier, I create a little script called ddwrt_env.sh which configures the right toolchain into $PATH:
#!/bin/sh
export GCCARM=/opt/ddwrt-toolchains/toolchain-arm_cortex-a9_gcc-6.1.0_musl-1.1.15_eabi/bin
export PATH=$GCCARM:$PATH
source ~/ddwrt_env.sh
This adds the required toolchain into $PATH and can be used for cross-compiling. You want to modify this, if you need to use a different toolchain
You will need the libmnl and ipset source, libmnl is a dependency of ipset. You can change the version required if needed
wget https://www.netfilter.org/projects/libmnl/files/libmnl-1.0.4.tar.bz2
wget http://ipset.netfilter.org/ipset-6.32.tar.bz2
Extract both archives:
tar vxf libmnl-1.0.4.tar.bz2
tar vxf ipset-6.32.tar.bz2
First you'll need to build libmnl to refer to the library sources later on.
cd libmnl-1.0.4
You'll need to build the source with the correct host definition. You can use the toolchain content to determine the correct value.
./configure --host=arm-openwrt-linux --enable-static --disable-shared
If everything was successful, run make
make
The source should now be built. We won't install libmnl as we only need the library files when we build ipset.
First run the autogen.sh file.
./autogen.sh
Next you'll need to cross-compile, referencing the libmnl libs as well as the appropriate host value, kernel source directory and making sure we don't build any kernel modules, as we do this separately with the DD-WRT source tree. You may want to adjust any paths set here if they differ from your setup.
$HOME corresponds to the home directory of the user you are running as.
./configure libmnl_CFLAGS="-I$HOME/libmnl-1.0.4/include" libmnl_LIBS="-L$HOME/libmnl-1.0.4/src/.libs -lmnl" --host=arm-openwrt-linux --with-kbuild=$HOME/dd-wrt/src/linux/universal/linux-4.4 --with-kmod=no --enable-static --disable-shared
If everything was successful, you can then run make:
make
If compiling was successful you will find a static ipset binary within the src/ folder. This can be placed onto your router to run. You should place it in an appropriate place i.e. /jffs or /opt where DD-WRT looks in its PATH variable for binaries. Example DD-WRT path:
/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