Dynamic IP using Cloudflare

Dynamic IP using Cloudflare

I previously posted an article about updating your DNS with your dynamic IP using paid service noip.com. I recently found out that you can do the same for free using Cloudflare.


  1. Registered an account with Cloudflare.
  2. Domain configured and active in Cloudflare. If not, read my post on how to configure one.
  3. Installed curl and jq.

Copy the content below into update.sh.

json='Content-Type: application/json'
dns_id=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records?type=A&name=$domain" -H "X-Auth-Email: $email" -H "X-Auth-Key: $api_key" -H "$json"|jq -r .result[0].id)
#echo -n $dns_id
ip=$(curl checkip.amazonaws.com)
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$dns_id" -H "X-Auth-Email: $email" -H "X-Auth-Key: $api_key" -H "$json" \
--data '{"type":"A","name":"'$domain'","content":"'$ip'","ttl":1,"proxied":true}'
Create a sub domain for you to update dynamically
This is where you can get your global API key
Once clicked [View], your API key will be shown
You can get your Zone ID here

The API I used can be found here

List DNS Records

Update DNS Record


Dynamic IP using noip.com

Dynamic IP using noip.com


  1. Ubuntu/Linux machine running at home with dynamic IP.
  2. Ubuntu/Linux machine is configured in DMZ or has port 80 forwarded to it.
  3. Registerd a free account at noip.com.

Bash script below to automatically get your external IP and and update noip.com. After that put this script to run as a cron job.

myip=$(curl checkip.amazonaws.com)
curl http://$username:$password@dynupdate.no-ip.com/nic/update?hostname=$hostname&myip=$myip





Ubuntu compress files

Ubuntu compress files and/or directories


Gzip does a decent job of compressing files and folders, and it is relatively fast too. The command to compress is:

tar -czvf compressed.tar.gz file_or_directory_i_want_to_compress

And the command to extract is:

tar -xzvf compressed.tar.gz


Bzip2 compressES more but it is slower.

The command to compress is:

tar -cjvf compressed.tar.bz2 file_or_directory_i_want_to_compress

The command to extract is:

tar -xjvf compressed.tar.bz2

SMS Gateway check inbox

SMS Gateway check inbox

To check the SMS you received while SMS Gateway Android app is running. Just make a POST HTTP call to SMS Gateway with your user and token using curl or wget in MacOS or Linux. You can use PowerShell in Windows 10 or use Postman if you prefer a graphical user interface (GUI).


My preferred method for HTTP POST in MacOS or Ubuntu. It is not preinstalled in Ubuntu desktop, you will need to install it with the following command.

sudo apt-get install curl

To check your SMS received using curl. Type in the following command.

curl -s \
--form-string "user=yga6pCt1h83knBnAqDfpunkCsno62b4EH11x" \
--form-string "token=GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF" \


If you prefer wget over curl, type in the following command. The -q is for quiet so that you don’t get all the verbose message output from the wget command. The -O – (is an uppercase O just in case you confuse it with zero) is to output it to screen instead of saving it to file.

wget -q -O - --post-data "user=yga6pCt1h83knBnAqDfpunkCsno62b4EH11x&token=GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF" https://sgw.oofnivek.com/inbox/check


If you are running Windows 10, you can run PowerShell, type in the following command to check the SMS received. I have not tested it with the PowerShell in other Windows version other than Windows 10.

[email protected]{user='yga6pCt1h83knBnAqDfpunkCsno62b4EH11x';token='GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF'}
Invoke-WebRequest -Uri https://sgw.oofnivek.com/inbox/check -Method POST -Body $body


With Postman, just fill in all the required fields, choose the HTTP message type and hit the [Send] button. Required fields are URL, user and token. The HTTP type will be POST. Click the [Send] button. You can see the JSON output nicely formatted when you on the [Pretty] button as shown below.

sms gateway check inbox
Successful HTTP POST message to check SMS received from SMS Gateway.

SMS Gateway queue message

SMS Gateway queue message

If you are running MacOS or Linux you can simply just use curl or wget to queue a message into SMS Gateway so that your Android phone can pick it up and send. If you are running Windows then you can use PowerShell or if you are a GUI person then install Postman.


In MacOS curl is already preinstalled therefore you can immediately use it once you open up your terminal. As for Ubuntu desktop, you will need to install curl by typing

sudo apt-get install curl

Once installed you can type the following curl command to send a POST HTTP message to SMS Gateway to queue your SMS message. The user and token below are dummy values, please replace it with your own user and token.

curl -s \
--form-string "user=yga6pCt1h83knBnAqDfpunkCsno62b4EH11x" \
--form-string "token=GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF" \
--form-string "destination=+6587654321" \
--form-string "message=hello world" \ https://sgw.oofnivek.com/message/queue


If you prefer to use wget over curl, you can type the command below to send a POST HTTP message. I’ve added the parameter -q for quiet so that I don’t see all the verbose message from wget. Besides that I also added the -O – (it is an uppercase O, just in case you can’t differentiate it with zero) parameter so that the result of the HTTP POST call will be output to the screen instead of saving into a file.

wget -q -O - --post-data "user=yga6pCt1h83knBnAqDfpunkCsno62b4EH11x&token=GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF&destination=+6587654321&message=hello world" https://sgw.oofnivek.com/message/queue


For PowerShell, I’m breaking the commands into two lines. First for the post params and values. Second to send to POST HTTP message.

[email protected]{user='yga6pCt1h83knBnAqDfpunkCsno62b4EH11x';token='GsiLTcNvgkVJWF9hLgYwwMiY1iE5W8pr4TyF';destination='+6587654321';message='hello world'}
Invoke-WebRequest -Uri https://sgw.oofnivek.com/message/queue -Method POST -Body $body


Postman provides a nice graphical user interface (GUI) for you to enter all the parameter’s name and value. Select the POST HTTP type and the URL you are posting the message to. Once all the field are filled up just hit the [Send] button.

sms gateway queue message
A successful HTTP POST message to SMS Gateway.



To remove JPG EXIF meta in Ubuntu with ease, you will need to install libimage-exiftool-perl. To install libimage-exiftool-perl and remove EXIF from myimage.jpg, type the following commands.

sudo apt-get install libimage-exiftool-perl
exiftool -all= myimage.jpg
remove jpg exif
EXIF tools installation in Ubuntu.


If you just want to view the JPG EXIF meta but not removing it. Just type

exiftool myimage.jpg

Suppress Bash MySQL warning

Install Ubuntu MySQL client

I assume you already installed MySQL client in your Ubuntu 16.04. If you had not, then to install MySQL client in Ubuntu, type in the following commands. Having a MySQL client is useless if you do not have a MySQL server to query. To install MySQL server, you can refer to my Ubuntu install WordPress blog post.

sudo apt-get update
sudo apt-get install mysql-client -y

Execute MySQL statement in Bash

To execute a MySQL statement in Bash, simply type in the following. I assume your MySQL server is hosted locally using the user “root” and with the password “password”.

mysql --host=localhost --user=root --password=password --execute='select now()'

Alternatively, you can use the shorter version to execute the same statement with the syntax below.

mysql -hlocalhost -uroot -ppassword -e'select now()'

Suppress Bash MySQL warning

Executing your MySQL statement in Bash with your password revealed in plain text will cause a warning to appear each time you execute a statement. It is quite annoying if you are running a loop executing MySQL statements with its output in stdout.

To suppress the warning, type the following commands. Key in your password when it prompts you for the password.

mysql_config_editor set --login-path=localhost --host=localhost --user=root --password

After that execute your MySQL statements using the syntax below. Both statements are the same, one long and one short depending on your preference. By executing it this way, MySQL warning is no longer there.

mysql --login-path=localhost --execute='select now()'
mysql --login-path=localhost -e'select now()'
suppress mysql warning
Suppressing MySQL warning by executing MySQL statement using login path.