OpenWrt Forum Archive

Topic: dnsmasq redirects

The content of this topic has been archived between 30 Apr 2018 and 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Lets go step by step.
Here is already (first) problem:

>1)ping book.shelf works (resolved to 192.168.251.252)
2)ping anything.else does not work
3)if i ping google then i get a reply from googles ip 82.94.234.18 (when i have a WAN connection)<

1) dnsmasq resolves book.shelf correctly.
     Shure, that it is DNSmasq ? Or do you have on your client in windows/system32/etc/hosts a line like
       192.168.251.252 book.shelf ?
     Because you must be shure, that dnsmasq REALLY is used to resolve dnsrequests from your client.
2) BUG. You need following line in dnsmasq.conf:
address=/#/192.168.251.252

No need for any further investigation, until the basic requiremens are met: dnsmasq REALLY is used to resolve dns-enquieries, AND dnsmasq works as expected.

Thanks Augustus!!!!

that fixed it.   I mistakenly used option address '/#/192.168.251.252' in the dnsmasq sectopn of the dhcp config file

now i have added address=/#/192.168.251.252 to dnsmasq.conf  and all is working.
I often looked in that file and it never came to mind that i could have tried to add it there..  DOH...

THANKS guys!  Also a big thank you to eduperez for helping me in the early stages. with a lot of the other stuff.

frietpan wrote:

...and all is working

Shall I post a HTTP 301 / 302 solution?

The thing i mainly was after was the catch all functionality and redirect all to a basic page.   A bit like 403, but without using authentication functionalities. Simply catch all and then point to one page. 

I thought there would be some way like Address=/#/192.168.x.x but then with an option to point to a URL. 

But yea, please post the 301 302 Permanent and temporary redirect method.

'one-liner' PHP script in /www/404.php:

<?php
header("Location: /index.php"); /* Redirect browser */
exit;
?>

/etc/config/dhcp:

    config dnsmasq
    ...
    list address '/#/192.168.1.1' /* <- IP address of web server (uhttpd) */

/etc/config/uhttpd:

    config uhttpd main
    ...
    option error_page /404.php

N.B. - requires PHP packages:

  • php5

  • php5-cgi

The discussion might have continued from here.