Giter Site home page Giter Site logo

dnsmasq-regex-openwrt's Introduction

Compile it as ipk

Simple steps to compile:

# Download openwrt sdk
wget https://downloads.openwrt.org/releases/xx.xx/targets/ipq40xx/generic/openwrt-sdk-xx.xx.tar.xz
tar xf openwrt-sdk*.tar.xz
cd openwrt-sdk*

# Update and install feeds
sudo apt-get install python3-distutils
./scripts/feeds update -a
./scripts/feeds install libpcre

# Disable some options related to kernel modules, They are located in 'Global Build Settings'
make menuconfig
Press SPACE to disable 'Select all target specific packages by default'
Press SPACE to disable 'Select all kernel module packages by default'
Press SPACE to disable 'Select all userspace packages by default'
Press ESC twice to exit and save.

# Clone the source of dnsmasq-regex
pushd package
git clone https://github.com/lixingcong/dnsmasq-regex-openwrt -b openwrt-23.05
popd

# Config modules. It was located in 'Base System'
make menuconfig
Press M to compile dnsmasq as a module

# (Optional) Speed up the compile progress
Press SPACE to disable useless 'libatomic', 'libgomp', 'librt', 'libstdcpp'

# Compile dnsmasq
make package/dnsmasq-regex-openwrt/compile V=s

# Copy the binary if you like
find bin/packages | grep dnsmasq

Notes

Toolchain version mismatch

You may get segmentation fault if you built it with different toolchain(for example, install dnsmasq to openwrt-22.03, while package was built under 19.07)

You'd better build full openwrt again if new version was released.

Get rid of procd-ujail

If you could not run dnsmasq, run logread and check if error occurred like this:

daemon.crit dnsmasq[1]: cannot access directory /etc/dnsmasq.d/: No such file or directory

Consider adding option confdir /etc/dnsmasq.d to /etc/config/dhcp to get file access permission.

Or you can add procd_add_jail_mount /etc/dnsmasq.d to /etc/init.d/dnsmasq, a few lines before procd_close_instance

Check for this issue for more details.

Where does the patch come from?

The patch is from dnsmasq-regex, and 900-regex-server-ipset.patch is produced by quilt command.

How to use quilt to deploy patches
# Dir of openwrt
cd $OPENWRT_ROOT

# Install upstream dnsmasq
./scripts/feeds install dnsmasq

# Move the upstream dnsmasq folder to custom one
rm package/feeds/base/dnsmasq
mv feeds/base/package/network/services/dnsmasq package/dnsmasq-regex-openwrt

# Change dnsmasq-regex-openwrt/Makefile to add some build flags
Example: COPTS = -DHAVE_REGEX -DHAVE_REGEX_IPSET

# Apply patches from dnsmasq-regex repo
make package/dnsmasq-regex-openwrt/{clean,prepare} V=s QUILT=1
cd $OPENWRT_ROOT/build_dir/target*/dnsmasq-nodhcpv6/dnsmasq-*

# Apply all patches maintained by Openwrt developers
quilt push -a

# If you want to apply several patches(not all), run 'quilt push xxx' many times
# quilt series
# quilt push 001-xxx.patch
# quilt push 999-xxx.patch

# Create a regex patch
quilt new 900-regex-server-ipset.patch

quilt add Makefile
quilt add src/config.h
quilt add src/dnsmasq.h
quilt add src/domain-match.c
quilt add src/forward.c
quilt add src/network.c
quilt add src/option.c

# Aplly patches from dnsmasq-regex
patch -p1 < /path/to/001-regex-server.patch
patch -p1 < /path/to/002-regex-ipset.patch
quilt refresh

# Update and rebuild the package
cd $OPENWRT_ROOT
make package/dnsmasq-regex-openwrt/update V=s
make package/dnsmasq-regex-openwrt/{clean,compile} V=s

dnsmasq-regex-openwrt's People

Contributors

lixingcong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dnsmasq-regex-openwrt's Issues

有办法给smartdns增加正则表达式匹配吗?

smartdns比dnsmasq更加好用和更加高效. 但是缺少了regex匹配, 增加了很多条目. 不知道hub主是否有可能给smartdns打个补丁增加regex?

你的补丁真的很实用, 条目可以少很多

等着,终于开了issue

麻烦请看一下这些错误我应该如何解决?debian8.5 x64,在此环境下编译过ssr。另外请问如果要升级,我看官方最新是2.76,我是否只需要更改m文件的版本号就可以了?

/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
^
mips-openwrt-linux-musl-gcc -Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75:dnsmasq-2.75 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -ffunction-sections -fdata-sections -DHAVE_DNSSEC -DVERSION='"2.75"' -c dnssec.c
In file included from dnsmasq.h:85:0,
from dnssec.c:18:
/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
^
dnssec.c:22:24: fatal error: nettle/rsa.h: No such file or directory
compilation terminated.
/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75/Makefile:156: recipe for target 'dnssec.o' failed
make[4]: *** [dnssec.o] Error 1
make[4]: Leaving directory '/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75/src'
Makefile:82: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75'
Makefile:151: recipe for target '/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75/.built' failed
make[2]: *** [/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/build_dir/target-mips_34kc_musl-1.1.15/dnsmasq-full/dnsmasq-2.75/.built] Error 2
make[2]: Leaving directory '/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/package/dnsmasq'
package/Makefile:196: recipe for target 'package/dnsmasq/compile' failed
make[1]: *** [package/dnsmasq/compile] Error 2
make[1]: Leaving directory '/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64'
/root/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64/include/toplevel.mk:185: recipe for target 'package/dnsmasq/compile' failed
make: *** [package/dnsmasq/compile] Error 2
root@debian:~/OpenWrt-SDK-ar71xx-nand_gcc-5.3.0_musl-1.1.15.Linux-x86_64#

Question about NFTSet regex support

Hi) I really like your project and what you've done.
I'm going to switch to the last version of OpenWrt, where is no ipset support anymore. But nftset works by default there.

Will wour version support regex for NFTSets or does it already work?

15.05, 17.01 没有生效

感谢大佬的辛勤工作。

发现正则相关的补丁没有打到 15.05 17.01, 分支上面 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.