Sponsored Content
Full Discussion: How can I do this better?
Top Forums Shell Programming and Scripting How can I do this better? Post 303019720 by apmcd47 on Wednesday 4th of July 2018 01:01:19 PM
Old 07-04-2018
Quote:
Originally Posted by Rhysers
Hello,


Still learning over here. I made the below based on what I've learned so far and what I've stolen from others. It updates my dynDNS addresses, both IPv4 and v6. I'm looking to see what I could have done better or how those more experienced than me would have done it. Thanks for your time!
(It wont let me post links cuz I'm still new here so I dropped one of the 't's in the URLs on purpose)
I can't speak for the curls but the following gets rid of unecessary greps, sed and cat.
Code:
#! /bin/bash

IP6=$(ip -6 -o addr show eno1 | awk '$4 ~ /64$/ && $4 ~ /200/ {$0 = $4;} sub("/.*","")') #All of this is to get one globally unique IPv6
#echo "IPv6 Address is $IP6"
last_ip_file="/tmp/last_ip"
last_ip=$( <$last_ip_file )
ip=$(curl -s htp://dynamicdns.park-your-domain.com/getip)
#echo "IPV4 is $ip"
if [ "$ip" == "$last_ip" ]; then
        #echo "IP Still same, not need to update."
        exit 0
fi

response=$(curl -s "<HTPS://<UserName>:<API-Key>@members.dyndns.org/v3/update?hostname=<domain>.better-than.tv&myip=$ip,$IP6")
#echo $response
response=$(curl -s "htps://<UserName>:<API-Key>@members.dyndns.org/v3/update?hostname=<other domain>.better-than.tv&myip=$ip")
echo $ip > $last_ip_file

The only problem I have with my solution is what if the output format of ip changes so that your address is no longer in field 4?

Andrew
 
6TUNNEL(1)						      General Commands Manual							6TUNNEL(1)

NAME
6tunnel - tunnelling for application that don't speak IPv6 SYNOPSIS
6tunnel [ -146dhfv ] [ -u username ] [ -i password ] [ -I password ] [ -l local_host ] [ -L limit ] [ -p pid_file ] [ -m map_file ] local_port remote_host [ remote_port ] DESCRIPTION
6tunnel allows you to use services provided by IPv6 hosts with IPv4-only applications and vice-versa. It can bind to any of your IPv4 (default) or IPv6 addresses and forward all data to IPv4 or IPv6 (default) host. For example 6tunnel -1 6668 irc6.net 6667 will be enough to connect to IPv6 irc server with irc foobar localhost:6668 If you don't wish to run 6tunnel every time you want to show your :c001: or :dead: IPv6 address on IRC, you can use -i parameter, which makes 6tunnel ask your client for specified password. Just run 6tunnel -i dupa.8 31337 irc6.net 6667 and then type irc foobar localhost:31337:dupa.8 If your IRC server requires you to send password, specify it with -I parameter -- after successful proxy authentication 6tunnel will send it to the server. 6tunnel can also be used as a tunnel for all other combinations of IPv4 and IPv6 endpoints. If remote host doesn't have any IPv6 addresses, 6tunnel will use the IPv4 one. In other cases, use -4 parameter which makes IPv4 address the preffered one. For IPv6-to-any tunnels use -6 which makes 6tunnel bind to IPv6 address. OPTIONS
-1 Exit after first connection. -4 Preffer IPv4 endpoint if the machine has both address types. -6 Listen on IPv6 address (IPv4 is default). -d Don't detach. -f Force tunneling even if remote host is not resolvable at the execution time. -h Print hex dump of every packet received or sent (hu-huh, Beavis, he said hex dump!) -u username Change UID and GID after bind(). -i password Act as an IRC proxy and require user to authenticate. -I password If you are using 6tunnel as an IRC proxy and the IRC server requires you to send password, place it right here. -l local_host Listen on specified address (IPv4, or IPv6 if -6 used). -L limit Limit simultaneous connections. -p pid_file Write down pid to specified file. -s source_host Connect to the remote host using specified source address. -m map_file Binds to specified IPv6 addresses on basis of source IPv4 address. The file contains one mapping per line with IPv4 source address and corresponding IPv6 address. Only listed hosts are allowed to connect. If you want to allow any host, add mapping for default or 0.0.0.0 address. Example: 192.168.0.2 3ffe:8010:18::1000:2 192.168.0.3 3ffe:8010:18::1000:3 -v Be verbose and don't detach. SIGNALS
Sending SIGHUP forces map file reload. THANKS
#ipv6 crew, Lam. BUGS
Terrible man page. Hex dump doesn't include IRC proxy authentication. IRC proxy requires your client to send password first (don't worry ircii, EPIC, BitchX, mIRC and many more will work). No logging except debug output. AUTHORS
Wojtek Kaniewski (wojtekka@toxygen.net), Dariusz Jackowski (ascent@linux.pl), Ramunas Lukosevicus (lukoramu@parok.lt) SEE ALSO
ssh(1) Aug 18, 2005 6TUNNEL(1)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy