Hi,

On Wed, May 22, 2013 at 09:35:30PM +0200, Samuraiii wrote:
> Script was just checking (by sftp with public ssh keys for unprivileged
> account) if LAN (eth or wifi) address is up and if not it just assigned
> address to hostname from vpn range (it did not accounted if machine is
> up or down). And the just write new /etc/hosts.
>
I'm using something similar but more sophisticated. On my machines I have
two hosts files, one for vpn, one for lan. Everytime I activate vpn on my
machine, a symlink to the "vpn" hosts is created. Upon deactivation of my vpn
the symlink points to the "normal" hosts. It looks like this:

lrwxrwxrwx 1 root root   17 Feb  3 23:24 /etc/hosts -> /etc/hosts.normal
-rw-r--r-- 1 root root 1354 Feb 19 04:49 /etc/hosts.normal
-rw-r--r-- 1 root root 1420 Feb  3 16:09 /etc/hosts.vpn

I use OpenVPN for my vpn, which calls the scripts up.sh and down.sh during
de/activation. I simply put a appropriate "ln" command at the end of these 
scripts.

Sure not the best solution, but if you only have a few machines it is good
and simple enough.

-- 
regards
 alex

Reply via email to