Gentoo Archives: gentoo-user

From: Samuraiii <samurai.no.dojo@×××××.com>
To: gentoo-user <gentoo-user@l.g.o>
Subject: [gentoo-user] Re: VPN vs LAN address hostname resolution
Date: Fri, 31 May 2013 16:32:27
Message-Id: 51A8D089.3060106@gmail.com
In Reply to: [gentoo-user] Re: VPN vs LAN address hostname resolution by Samuraiii
1 I am terribly sorry but i posted wrong version (one from clipboard not
2 actually right one so again).
3 You can edit what you want (eg hashing or anything else). I don't know
4 how to stop it from init.d script gracefully (for now I have there kill
5 -9 pid). I thing the problem is in the loop (while /bin/true).
6
7 #!/bin/sh
8 #verze 2.0.0_2013-05-31
9 lock=/var/run/hostnames-updater.pid
10 shmm="/dev/shm/hosts"
11
12 clean () {
13 rm $lock
14 rm $shmm
15 }
16 trap clean SIGHUP SIGINT SIGTERM
17
18 /bin/echo $$ > $lock
19 while /bin/true
20 do
21 tst(){
22 x=0
23 if /usr/bin/test $3 = $(/usr/bin/ssh-keyscan -p $2 $5
24 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep)
25 then
26 x=$5
27 elif /usr/bin/test $1 -gt 2
28 then
29 if /usr/bin/test $3 = $(/usr/bin/ssh-keyscan -p $2 $6
30 2>/dev/null|/bin/sed 's/.*\ ssh-.*\ //g'|/usr/bin/whirlpooldeep)
31 then
32 x=$6
33 else
34 x=$4
35 fi
36 else
37 x=$4
38 fi
39 }
40
41 ####################host1
42 tst <address count> <port> <hash> <fallback address> <address 1> ...
43 <addressn> 2>&1 >/dev/null
44 host1=$x
45 ####################AJA
46
47
48
49
50 /bin/echo "# /etc/hosts: Local Host Database
51 #
52 # This file describes a number of aliases-to-address mappings for the for
53 # local hosts that share this file.
54 #
55 # In the presence of the domain name service or NIS, this file may not be
56 # consulted at all; see /etc/host.conf for the resolution order.
57 #
58
59 # IPv4 and IPv6 localhost aliases
60 127.0.0.1 $(hostname).local $(hostname) localhost
61 ::1 localhost
62
63 #
64 # Imaginary network.
65 $host1 hostname1
66 # Last update $(date --rfc-3339=ns)
67
68 #
69 #
70 # According to RFC 1918, you can use the following IP networks for private
71 # nets which will never be connected to the Internet:
72 #
73 # 10.0.0.0 - 10.255.255.255
74 # 172.16.0.0 - 172.31.255.255
75 # 192.168.0.0 - 192.168.255.255
76 #
77 # In case you want to be able to connect directly to the Internet (i.e. not
78 # behind a NAT, ADSL router, etc...), you need real official assigned
79 # numbers. Do not try to invent your own network numbers but instead
80 get one
81 # from your network provider (if any) or from your regional registry (ARIN,
82 # APNIC, LACNIC, RIPE NCC, or AfriNIC.)
83 #
84 " > $shmm
85 /bin/mv $shmm /etc/hosts
86 /usr/bin/sleep 120
87 done