You are not logged in.

#1 2014-06-17 21:18:46

supershnee
Member
Registered: 2014-06-17
Posts: 2

How can I resolve all external addresses to an internal address ?

I am using a raspberry-pi running ArchLinux with a WiFi router to provide an access point for locally-hosted web content. I am running a DHCP server. When the Pi is plugged into an internet connection, clients connected to it's WiFi network can access any webpage online as well as accessing locally hosted content (via 10.1.0.1).

When an internet connection is not present, I would like all DNS requests to route to 10.1.0.1. However, I only want this behavior to occur if the DNS request to the real webpage (say www.google.com) does not resolve. How can I conditionally resolve all external addresses to the internal address, only when internet access is not available (when an external dns request fails to resolve)?

This question is similar to How can i resolve all external addresses to internal address?, but I am not clear how to apply dnsmasq conditionally, or whether dnsmasq is the correct tool for my use case.

Offline

#2 2014-06-17 22:33:18

stevenhoneyman
Member
From: England
Registered: 2014-05-25
Posts: 241

Re: How can I resolve all external addresses to an internal address ?

I'd look into using iptables for something like that I think

something like

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.1.0.1

(to be added/removed whenever your 'net goes down)

Last edited by stevenhoneyman (2014-06-17 22:43:13)

Offline

#3 2014-06-20 14:52:28

-Syu
Member
Registered: 2012-01-24
Posts: 29

Re: How can I resolve all external addresses to an internal address ?

I think dnsmasq would do well at that, but you might have to run two instances for your scenario.

My idea would be to configure dnsmasq to try all parent resolvers in a fixed order (as opposed to favouring the fastest), and putting a public DNS server in the list of parents before your second instance of dnsmasq. That second instance would reply with only local addresses, but it would only be queried if the public DNS server fails (or times out).

You might be able to do this with only one instance, though, if it's possible to make that instance's own static records "rank" lower. (By default, it does the opposite.)

Offline

Board footer

Powered by FluxBB