From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4167F1381F3 for ; Fri, 31 May 2013 16:05:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 617B5E0946; Fri, 31 May 2013 16:04:43 +0000 (UTC) Received: from we1-f189.wedos.net (we1-f189.wedos.net [46.28.105.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E0D82E0930 for ; Fri, 31 May 2013 16:04:41 +0000 (UTC) Received: from ([94.113.166.116]) by we1-f189.wedos.net (WEDOS Mail Server mail1) with ASMTP (SSL) id QZJ00038; Fri, 31 May 2013 18:04:38 +0200 Message-ID: <51A8CA14.6030506@gmail.com> Date: Fri, 31 May 2013 18:04:36 +0200 From: Samuraiii User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130526 Thunderbird/17.0.6 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 To: gentoo-user Subject: [gentoo-user] Re: VPN vs LAN address hostname resolution References: <519CF41B.5040108@gmail.com> In-Reply-To: <519CF41B.5040108@gmail.com> X-Enigmail-Version: 1.6a1pre OpenPGP: id=80C752EA X-TagToolbar-Keys: D20130531180436650 Content-Type: multipart/alternative; boundary="------------010602080406080802040400" X-Archives-Salt: 6a0b532c-bdc8-4d09-9c87-ced5f786f30d X-Archives-Hash: 83dc06059fac22de81df654331350a97 This is a multi-part message in MIME format. --------------010602080406080802040400 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit If someone is intrested here is second (undebugged) incarnation of my hostnames updater script: #!/bin/sh #verze 2.0.0_2013-05-31 lock=/var/run/hostnames-updater.pid shmm="/dev/shm/hosts" clean () { rm $lock rm $shmm } trap clean SIGHUP SIGINT SIGTERM /bin/echo $$ > $lock while /bin/true tst(){ x=0 if $3 = $(/usr/bin/ssh-keyscan -p $2 $5 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirpooldeep) then x=$5 elif /usr/bin/test $1 -gt 2 then if $3 = $(/usr/bin/ssh-keyscan -p $2 $6 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep) then x=$6 else x=$4 fi else x=$4 fi } #host testing line is as folows #tst \ #
2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep> \ #
####################host 1 tst
...
2>&1 >/dev/null host1=$x #lets create hosts file /bin/echo "# /etc/hosts: Local Host Database # # This file describes a number of aliases-to-address mappings for the for # local hosts that share this file. # # In the presence of the domain name service or NIS, this file may not be # consulted at all; see /etc/host.conf for the resolution order. # # IPv4 and IPv6 localhost aliases 127.0.0.1 $(hostname).local $(hostname) localhost ::1 localhost # # Imaginary network. $host1 host1 # Last update $(date --rfc-3339) # # # According to RFC 1918, you can use the following IP networks for private # nets which will never be connected to the Internet: # # 10.0.0.0 - 10.255.255.255 # 172.16.0.0 - 172.31.255.255 # 192.168.0.0 - 192.168.255.255 # # In case you want to be able to connect directly to the Internet (i.e. not # behind a NAT, ADSL router, etc...), you need real official assigned # numbers. Do not try to invent your own network numbers but instead get one # from your network provider (if any) or from your regional registry (ARIN, # APNIC, LACNIC, RIPE NCC, or AfriNIC.) # " > $shmm /bin/mv $shmm /etc/hosts /usr/bin/sleep 300 done I hope I helps someone S --------------010602080406080802040400 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit If someone is intrested here is second (undebugged) incarnation of my hostnames updater script:

#!/bin/sh
#verze 2.0.0_2013-05-31
lock=/var/run/hostnames-updater.pid
shmm="/dev/shm/hosts"

clean () {
    rm $lock
    rm $shmm
}
trap clean SIGHUP SIGINT SIGTERM

/bin/echo $$ > $lock
while /bin/true
    tst(){
    x=0
    if $3 = $(/usr/bin/ssh-keyscan -p $2 $5 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirpooldeep)
    then
        x=$5
    elif /usr/bin/test $1 -gt 2
    then
        if $3 = $(/usr/bin/ssh-keyscan -p $2 $6 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep)
        then
            x=$6
        else
            x=$4
        fi
    else
        x=$4
    fi
    }

#host testing line is as folows
#tst <number of addresses to try - some hosts do have wl and eth interface)> \
#<output of  ssh-keyscan -p <port> <address> 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep> \
#<fallback address - eg. vpn one> <address 2> <address n>

####################host 1
tst <address count n> <port> <hash> <address 1 > ... <address n> 2>&1 >/dev/null
host1=$x


#lets create hosts file
/bin/echo "# /etc/hosts: Local Host Database
#
# This file describes a number of aliases-to-address mappings for the for
# local hosts that share this file.
#
# In the presence of the domain name service or NIS, this file may not be
# consulted at all; see /etc/host.conf for the resolution order.
#

# IPv4 and IPv6 localhost aliases
127.0.0.1    $(hostname).local $(hostname) localhost
::1        localhost

#
# Imaginary network.
    $host1        host1
#    Last update $(date --rfc-3339)

#
#
# According to RFC 1918, you can use the following IP networks for private
# nets which will never be connected to the Internet:
#
#       10.0.0.0        -   10.255.255.255
#       172.16.0.0      -   172.31.255.255
#       192.168.0.0     -   192.168.255.255
#
# In case you want to be able to connect directly to the Internet (i.e. not
# behind a NAT, ADSL router, etc...), you need real official assigned
# numbers.  Do not try to invent your own network numbers but instead get one
# from your network provider (if any) or from your regional registry (ARIN,
# APNIC, LACNIC, RIPE NCC, or AfriNIC.)
#
" > $shmm
/bin/mv $shmm /etc/hosts
/usr/bin/sleep 300
done


I hope I helps someone
S
--------------010602080406080802040400--