Listen to DNS request

Hey,

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

Is it possible with OpenWRT ?

Thnaks

@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.

3 Likes

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?

2 Likes

Hey,
I want to listen to all DNS request, and if I "see" a DNS request like "host.com" ,I want to return a new web server that I open in 192.168.1.1:81

I added these lines to /etc/hosts:
192.168.1.1:81 host.com
192.168.1.1 luci.com

but when I search for "luci.com" it's works and "host.com" 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. https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#domains
It doesn't work with port though.

2 Likes

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 '0.0.0.0:80'
	list listen_http '[::]:80'
	list listen_https '0.0.0.0:443'
	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.

Thnaks

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. )

3 Likes

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

1 Like