Easy FIX for running a Massa node with a Dynamic ip

If you are reading this, you are probably running a Massa node from home and you do not have a static ip. In this case any router restart would change the ip and you end up in losing your rolls and important score points.

Manage your Massa node with SystemD – MassAdopted.com

Here we go
Install HttpHeaders extension for Chrome

Getting the Discord authorization key and the ID of the private chat with MassaBot

Will be using Chrome browser for the purpose of this tutorial.

Visit https://discord.com/app login to your discord account in your browser and open the private chat with MassaBot. You should be getting something like bellow.

Open HttpHeaders located on the right top

Click on “Live”

Now go to Discord tab where you have your private chat with MassaBot and send an “info” command.

Go back to your HttpHeaders tab, select “Discord” on “Filter by tabs”. Look for a Request that looks similar to the one in the picture bellow and save the private chat ID link, the one that looks like:

https://discord.com/api/v9/channels/996482750976634960/messages

Click on the “REQ” header which will give you additional info on the right column, including your Authorization key. Save it as we need it in the next step, private chat ID also.

Now that we have our Discord authorization key and private chat ID lets move to the next step.

See also  Massa x GGH Hackathon
Connect to your server with Putty (root access)

Modify the code bellow with your Authorization key and private channel ID that you saved at the begining, also if you have IPV6 ip, modify the line

cur=$(dig -4 +short ANY @resolver1.opendns.com myip.opendns.com)

to

cur=$(dig -6 +short ANY @resolver1.opendns.com myip.opendns.com)

#!/bin/bash
prev=$(cat workingip.txt)
while true; do
cur=$(dig -4 +short ANY @resolver1.opendns.com myip.opendns.com)
if [ "$prev" != "$cur" ]; then
prev="$cur"
echo "$cur"
rm massa/massa-node/config/config.toml
echo -e "[network]\nroutable_ip = \""$cur"\"" >> massa/massa-node/config/config.toml
rm workingip.txt
echo -e "$cur" >> workingip.txt
sudo systemctl restart massad
curl -v \
-H "Authorization: OTQxMDIxMTA4ODA1NzA5OTA0.GH6_u_.iKfOG3wTr1TuXBR_Vrjrz0qoeOVHjUu9VTPFfE" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"content\":\"$cur\"}" \
https://discord.com/api/v9/channels/996493750966634960/messages
exit 0
fi
echo "$cur"
exit 0
done

 

 

 Type sudo cat > /root/getip and hit enter. Copy/Paste your modified code above and hit Ctrl+D to save the file

Create a Systemd Service and timer so our script will execute once a few minutes to check if the ip was changed

While still with Putty connection opened, go ahead and do the bellow command, Copy/Paste all at once in Putty to create the “get_ip.service” file:

printf "[Unit]
Description=A job to test the systemd scheduler
[Service]
Type=forking
WorkingDirectory=/root
ExecStart=bash /root/getip
[Install]
WantedBy=default.target" > /etc/systemd/system/get_ip.service

Now for the “get_ip.timer” file do the same with the code bellow:

printf "[Unit]
Description=Get Ip for Massa
RefuseManualStart=no  # Allow manual starts
RefuseManualStop=no   # Allow manual stops
[Timer]
OnCalendar=*:4/4
#File describing job to execute
Unit=get_ip.service
[Install]
WantedBy=timers.target" > /etc/systemd/system/get_ip.timer

We have created our Systemd files that will run our script every 4 minutes to check for the ip change. Lets go ahead and enable the service. Still on Putty, give the commands bellow one by one:

sudo systemctl daemon-reload

sudo systemctl enable get_ip.service

sudo systemctl enable get_ip.timer

sudo systemctl start get_ip.timer

Now to check if the timer service is active:

See also  Who are these 3 shadows ? three blockchain projects ?

sudo systemctl status get_ip.timer

You should see a count-down on-going untill the service will be executed again.

Voila !!! You are done, wasn’t that hard.

Total
0
Shares
1 comment
Leave a Reply to dockyr Cancel reply

Your email address will not be published. Required fields are marked *

Previous Post
Last week's Hot Altcoin events

Last week’s Hot Altcoin events

Next Post

Presenting Masstronauts Series: Interview with Benoit@Dockyr


Disclaimer : This website does not invite anyone to invest in the projects we are talking about. This is simple information about crypto projects that we find interesting.
Related Posts
PhilippinesFrenchSpainUkraineRomania