LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   noip3 / noip-duc - script for boot (https://www.linuxquestions.org/questions/slackware-14/noip3-noip-duc-script-for-boot-4175735121/)

inukaze 03-20-2024 07:23 PM

noip3 / noip-duc - script for boot
 
Hi there some days ago i download and install "noip3" client using the follow commands

Code:

#Install noip client :
mkdir /tmp/noip
cd /tmp/noip
wget https://dmej8g5cpdyqd.cloudfront.net/downloads/noip-duc_3.0.0.tar.gz
tar xf noip-duc_3.0.0.tar.gz
cd noip-duc_3.0.0/binaries
deb2tgz noip-duc_3.0.0_amd64.deb
su -c "installpkg noip-duc_3.0.0_amd64.txz ; ldconfig" root

Code:

#Removing noipclient :
su -c "removepkg noip-duc_3.0.0_amd64.txz ; ldconfig" root
Contraseņa:
Removing package: noip-duc_3.0.0_amd64
Removing files:
  --> Deleting /lib/systemd/system/noip-duc.service
  --> Deleting /usr/bin/noip-duc
  --> Deleting /usr/share/doc/noip-duc/README.md
  --> Deleting /usr/share/doc/noip-duc/copyright
  --> Deleting empty directory /usr/share/doc/noip-duc/

Well if you notice just one file relevant, the binary executable client.

Configuring the things, like my account on "noip" website, password, ddns data.

On some moment i should use the follow command :
Code:

iptables -I INPUT -s [DISIRED_IP] -p tcp -m tcp --dport [DESIRED_PORT] -j ACCEPT
iptables -I INPUT -s [DISIRED_IP] -p udp -m udp --dport [DESIRED_PORT] -j ACCEPT

echo 'on more clear example :'
iptables -I INPUT -s inukazenoip.redirectme.net -p tcp -m tcp --dport 22 -j ACCEPT

iptables -I INPUT -s inukazenoip.redirectme.net -p udp -m udp --dport 22 -j ACCEPT

Well the thing is i am thinking how i should write my script for start noip client during boot, by the moment i had just write the follow

Code:

#!/usr/bin/env bash
# Author    :        Inukaze ( Venezuela )
# WebSite  :        http://https://goo.gl/ij6WqW
# E-Mail    :        bloginukaze@gmail.com
# License  :        GPL 2

function noip-duc()
{
noipduc=$(whereis -B "/usr/sbin" "/usr/local/sbin" "/sbin" "/usr/bin" "/usr/local/bin" "/bin" -b noip-duc | grep -i "noip-duc" | cut -d " " -f02 | sed 's/[/]noip-duc//')

noipduc=$(echo "$noipduc/noip-duc")

while getopts u:p: flag
do
    case "${flag}" in
        u) username=${OPTARG};;
        p) password=${OPTARG};;
    esac
done
echo "Username: $username";
echo "Password: $password";
}

start() {
        if ! /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
                echo "Gateway not defined yet, please init the network services."
                exit 0;
        fi
        echo "Starting no-ip client daemon: "
        "$noipduc/noip-duc" --username "$username" --password "$password"
}

stop() {
                echo "Stopping no-ip client daemon: ";
                for i in `"$noipduc" 2>&1 | grep Process | awk '{print $2}' | tr -d ','`
                do
                        killall -9 "$noipduc"
                done
        else
                echo "no-ip client daemon is not running" && exit 0
        fi
}

status() {
        if "$noip-duc" 2>&1 | grep Process 1>/dev/null ; then
                echo "no-ip client daemon is running"
        else
                echo "no-ip client daemon is not runnig"
        fi
}

restart() {
        stop
        sleep 1
        start
}

case "$1" in
  start)
          start
        ;;
  stop)
          stop
        ;;
  status)
        status
        ;;
  restart)
          restart
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
esac

i think saved like /etc/rc.d/rc.noip

But someone had a better idea for this.

RudyMartin 03-21-2024 12:11 PM

Quote:

Originally Posted by inukaze (Post 6490918)
But someone had a better idea for this.

I fail to see your specific question but assuming you want to know if there's a better approach, I use afraid.org service. Updating the dynamic dns is just a wget line which you can get from the site when you register a subdomain. After, it all depends on how stable is your connection and ip address allocation time frame and what and how important are the services you are running on your "server". Best case scenario you might want to run an update once a day. Worst case scenario you might want to check your current public ip address (command ifconfig or ip a s) and compare with the public registered on your dynamic dns (command resolveip and egrep to extract ip) and run updates every ten minutes or any number you consider safe.


ymmv. hope it helps.


All times are GMT -5. The time now is 09:57 PM.