dynamic-ip clients?

Guus Sliepen guus at tinc-vpn.org
Mon Mar 23 13:29:34 CET 2009


On Mon, Mar 23, 2009 at 12:05:07PM +0100, lizard wrote:

> erf - again, this time with complete paste :)
> 
> #!/bin/sh
> file=/etc/tinc/$NETNAME/hosts/$NODE
> echo $file
> grep -Fq "#dynamic" $file || exit 0
> grep -Fq "Address = $REMOTEADDRESS" $file && exit 0
> grep -Fv "#dynamic" $file > $file.new
> echo "Address = $REMOTEADDRESS #dynamic" >> $file.new
> mv $file.new $file

Comments can only start at the beginning of a line, so putting #dynamic at the
end of the line might not work. You can vary whitespace if you want to
distinguish between manual and dynamic Addresses. To top you, the following
script that remembers the last 3 dynamic addresses and does not overwrite the
host config file when something goes wrong:

#!/bin/sh
file=/etc/tinc/$NETNAME/hosts/$NODE
grep -Fq "Address  =  $REMOTEADDRESS" $file && exit 0
grep -Fv "Address  =  " $file > $file.new &&\
echo "Address  =  $REMOTEADDRESS" >> $file.new &&\
grep -Fm 2 "Address  =  " $file >> $file.new &&\
mv $file.new $file

-- 
Met vriendelijke groet / with kind regards,
     Guus Sliepen <guus at tinc-vpn.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://www.tinc-vpn.org/pipermail/tinc/attachments/20090323/abde2079/attachment.pgp 


More information about the tinc mailing list