Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 1.62 KB

README.md

File metadata and controls

39 lines (33 loc) · 1.62 KB

show.me.the.ips

bash script part

bash script that should be put into one of your machines inside the local subnet which needs to recorgnize the outbound ip.
say, we named the script "sendipout.sh" and make it runnable:
please notice, that, you should replace "yourusername/yourmachinename/yourvmusername/yourvmipaddr" to your own ones. and, of course, set your ssh to yourvm (virtual machine) authorised in order to use scp without password.

curIP=$(curl ifconfig.cc)
loIP=$(cat /home/yourusername/.obip);
echo "current IP: $curIP, local saved IP: $loIP."
if [ "$curIP" = "$loIP" ]; then
        echo "it's a match."
else
        echo $curIP > /home/yourusername/.obip
        scp /home/yourusername/.obip yourvmusername@yourvmipaddr:/home/yourvmusername/.yourmachinename.obip;
fi

then, you need to create a crontab job like the following line (say every 30 minutes):

# m h  dom mon dow   command
0,30 * * * * /home/yourusername/sendipout.sh

node.js server part

first of all, node.js and other related stuff need to be installed on your vm (say our vm is "debian based" linux server kind of stuff).

apt install nodejs npm;
npm install express pug node-watch

then, please git clone this repository into your vm, and run it, it should be listening on port 21180.

cd /the/directory/that/you/just/cloned/it/into/;
node app.js

and please notice, again, that, you should change some codes in app.js, such as putting the reall path, like "/home/yourvmusername/.yourmachinename.obip", into array fn, if you know what i mean.