[Nottingham] Two Entries in /etc/hosts

Martin martin at ml1.co.uk
Thu Apr 28 12:26:39 UTC 2016


Ok... To jump in here...


I'm guessing that you have an ISP home-hub thingie and you want to
connect to some device that you have forwarded onto a DMZ on your home LAN.

>From the outside world, you expect connections to be slow. However, when
on the 'inside' on your own LAN, you want Gbit speeds...

So...


If you're using WiFi... Is the limiting factor the speed of your WiFi?

With an ISP home-hub device, you're rather at the mercy of what that
device can do...

Hence:

One option, is to have your DMZ device respond to TWO web names so that
you have one name resolve to your external forwarded IP address, and you
have a second name such as "name.homelan" resolve to the DMZ local
address. You then use human intelligence as to which name you use!

(Before the big name sell-off, a safe Top Level Domain name to use was
".lan". You could guarantee that would not resolve unless you had your
own name server or some entry in your hosts file. Now... Just wait for
the nefarious confusion when the ".lan" domain gets sold off!...)


Or:

Run your own internal name server which intercepts your DNS requests to
return an internal address for you. When on the 'outside', the external
DNS gives your external IP as normal.


Or:

You have two hosts files and some script that recognises when you are on
your home lan and swaps the host files accordingly.


Or:

Complicated kludge of adding a routing rule to your laptop when at home
that redirects your external IP address traffic directly to your DMZ device.



Of all those options...

Likely easiest and most obvious is to have a hosts file dedicated to
where you are and to flip between hosts files. (Being that is how you
control what is where already...)


As for detecting when you are on your home lan...

That is for another adventure of ideas :-)


Cheers,
Martin





On 27/04/16 10:05, Richard Parsons wrote:
> Hello folks
> 
> I use my /etc/hosts file in order to point certain hostnames at IP
> addresses around the internet. I would like the same hostname to point
> to a local IP address when I'm on my home network, and a public IP
> address when on any other network. How can I set this up?
> 
> I recently discovered that when I was copying things over my local
> network it was taking much longer because I was actually using my public
> IP address rather than the local one. It seems to make a significant
> difference to ping time etc. In fact, pinging myself through the public
> IP address seems to be massively less reliable and speedy than using a
> local IP (maybe that shouldn't be a surprise). I'm using mtr to test that.
> 
> It seems to me to be such a common problem, that there must be solutions
> out there just waiting to be used.
> 
> If it makes a difference I'm using Arch with netctl to manage my network
> connections.
> 
> Many thanks
> Richard




-- 
- ╔═══════════════════╦══════════════════════════════════════════╗
- ║   Martin Lomas    ║ OpenPGP (GPG/PGP) Public Key: 0xCEE1D3B7 ║
- ║ martin@ ml1 co uk ║ Import from   hkp://subkeys.pgp.net   or ║
- ║ ----------------- ║ http:// ml1 .co .uk/martin_ml1_co_uk.gpg ║
- ╚═══════════════════╩══════════════════════════════════════════╝



More information about the Nottingham mailing list