Listen to DNS request


I want to listen to all the DNS requests and update the requested URL ?

Is it possible with OpenWRT ?


@abitbul6, welcome to the community!

Can you better explain your use case:

  • Listen to all DNS requests to where?
  • Update the URL going to what?

Perhaps you don't realize the the two things you listed are usually two different processes on two different protocols.


Maybe you mean that you want to hijack the DNS replies and replace the answer with something else, then forward it to the lan host?


I want to listen to all DNS request, and if I "see" a DNS request like "" ,I want to return a new web server that I open in

I added these lines to /etc/hosts:

but when I search for "" it's works and "" does not work.

Any suggestion ?

something like that, but I want to return a local ip address

Not in /etc/hosts, but /etc/config/dhcp.
It doesn't work with port though.


Thanks !
So how can I run 2 instances of uhttpd on my openwrt.
my current etc/config/uhttp is look like:

config uhttpd 'main'
	list listen_http ''
	list listen_http '[::]:80'
	list listen_https ''
	list listen_https '[::]:443'
	option redirect_https '1'
	option home '/www'
	option rfc1918_filter '1'
	option max_requests '3'
	option max_connections '100'
	option cert '/etc/uhttpd.crt'
	option key '/etc/uhttpd.key'
	option cgi_prefix '/cgi-bin'
	list lua_prefix '/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
	option script_timeout '60'
	option network_timeout '30'
	option http_keepalive '20'
	option tcp_keepalive '1'
	option ubus_prefix '/ubus'

config cert 'defaults'
	option days '730'
	option key_type 'rsa'
	option bits '2048'
	option ec_curve 'P-256'
	option country 'ZZ'
	option state 'Somewhere'
	option location 'Unknown'
	option commonname 'OpenWrt'

config uhttpd 'llmp'
	option listen_http '81'
	option home '/srv/www'

but now they are on the same ip and different port.


seems your looking for an http server with a rewrite/smarthost engine...

try apache or nginx...

( or you'd have to add an additional ip @ veth/loopback/dummy etc. )


It won't work like this, is the proper way.

1 Like