Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Router

Running DD-WRT v24
DNSMasq is enabled
DynDNS is enabled, routing TLD domain devita.co to my Dynamic IP    
Port Fowarding rules enabled for 192.168.1.161, WAN 2152 -> LAN 80

External Accessible Services

- Remote Web Server running @:192.168.1.161 on port 80
  which runs a web interface for my raspberry pi

The Problem

If my phone is off the Wireless network i can access http://devita.co:2152 fine. However if i am on the local wireless or wired network. I have to use http://<localhostname>:<port> e.g; http://garagedoor. in order to access the respective device.

The Question

How can i access my remote services both locally and externally on the same TLD domain name (devita.co)?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There are two ways round this:

1) (the easiest) - see if your router supports "NAT Loopback" (may go by a different name depending on brand of router), if it doesn't - upgrade to one that does. This will immediately make your service work.

2) (The hardest) - This is really simply a workaround for when your router doesn't support nat loopback. You need to do something called "Split Brain DNS". This is where you have a different DNS server that your router forwards queries to instead of the main internet/ISP DNS one.

For example, if you installed a DNS server on your raspberry pi (bind is really simple to use in basic configuration), you could then set it to forward all queries to your DNS server of choice, but, you can host a file for the devita.co domain with the local ip.

This basically means that devices on your network will refer to this DNS server and get the internal IPs whilst machines out of the network will get the regular DNS and external IPs.

This is the official way it is done in some big networks, but, I personally do not like it!

... There are good reasons for both though, and even if the router does support NAT loopback, there are genuine reasons for using Split Brain DNS.

For example, if you have the local IP, you will make a direct connection - if you have the external IP and use natloopback, it will go via the router and as in its name, loopback and duplicate the data over the network. So, in large networks, there are genuine reasons for using this even if your router supports NAT Loopback... but, NAT loopback is so much easier!

share|improve this answer
    
Wow... I was on a roll! Should have just said "Your router needs to support NAT Loopback"! I like giving a workaround though and this really gives a good explanation about the alternatives. –  William Hilsum Mar 29 '13 at 17:25
    
option 1 was the solution, i ran the command iptables -t nat -A POSTROUTING -j MASQUERADE in dd-wrt's startup firewall script for the loopback. Now if only i can get my domain name to map sub domains to appropriate hostnames and mask the ports. –  gorelative Mar 29 '13 at 17:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.