Gentoo Archives: gentoo-user

From: Alex <alex@×××××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] VPN vs LAN address hostname resolution
Date: Wed, 22 May 2013 20:52:30
Message-Id: 20130522205218.GA1643@zengers.de
In Reply to: Re: [gentoo-user] VPN vs LAN address hostname resolution by Samuraiii
1 Hi,
2
3 On Wed, May 22, 2013 at 09:35:30PM +0200, Samuraiii wrote:
4 > Script was just checking (by sftp with public ssh keys for unprivileged
5 > account) if LAN (eth or wifi) address is up and if not it just assigned
6 > address to hostname from vpn range (it did not accounted if machine is
7 > up or down). And the just write new /etc/hosts.
8 >
9 I'm using something similar but more sophisticated. On my machines I have
10 two hosts files, one for vpn, one for lan. Everytime I activate vpn on my
11 machine, a symlink to the "vpn" hosts is created. Upon deactivation of my vpn
12 the symlink points to the "normal" hosts. It looks like this:
13
14 lrwxrwxrwx 1 root root 17 Feb 3 23:24 /etc/hosts -> /etc/hosts.normal
15 -rw-r--r-- 1 root root 1354 Feb 19 04:49 /etc/hosts.normal
16 -rw-r--r-- 1 root root 1420 Feb 3 16:09 /etc/hosts.vpn
17
18 I use OpenVPN for my vpn, which calls the scripts up.sh and down.sh during
19 de/activation. I simply put a appropriate "ln" command at the end of these scripts.
20
21 Sure not the best solution, but if you only have a few machines it is good
22 and simple enough.
23
24 --
25 regards
26 alex