Longshot; Conditional '/etc/hosts' depending on an iface's subnet?

Christopher Browne cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Mon Nov 30 21:16:26 UTC 2009


On Mon, Nov 30, 2009 at 3:30 PM, Madison Kelly <linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:
> Hi all,
>
>  I really doubt this is possible, but is there a way to have entries in
> '/etc/hosts' return an IP depending on what a given interface's subnet is?
>
>  The reason I ask is that when I am at work, I want a given name to resolve
> the internal IP, but when I am out I need it to resolve to it's external IP.
> I know I could do this with an internal DNS, but I am hoping there might be
> an easier way to do it. Currently I just use two different names.

1.  Two different names works...

2.  Creating custom DNS behaviour could presumably work...

3.  Is it conceivable that you might be able to use aliasing in
whatever service you're using?

For instance, when referencing my machines at home from anywhere else,
I'd *ALWAYS* be using ssh as the means of access, hence what has made
sense to do has been to put an entry in my work $HOME/.ssh/config file
containing the "moral equivalent" to what's in /etc/hosts at home.

So, if I'm at home, I'll most often be sshing to a host called "wolfe".

At work, $HOME/.ssh/config has a "wolfe" entry that points to that same host.

It works for me :-).
-- 
http://linuxfinances.info/info/linuxdistributions.html
Pablo Picasso  - "Computers are useless. They can only give you
answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list