Find Your External IP Address
It’s easy to find your internal IP address my using tools like ifconfig or ip a but to find your external IP address (the one that connects you to the outside world) you must use other means. Here are 3 simple commands that you can use to do just that:
$ curl ifcfg.me
72.76.yyy.xxx
$ curl icanhazip.com
72.76.yyy.xxx
$ nslookup myip.opendns.com. resolver1.opendns.com
Server: resolver1.opendns.com
Address: 208.67.222.222#53
Non-authoritative answer:
Name: myip.opendns.com
Address: 72.76.yyy.xxx
Tags: cli, network, curl, nslookup, motd
Sending Email from the Command Line with cURL
Let’s assume that you had a RFC 5822 formatted file named
mail.txt as follows:
From: Some Sender <[email protected]>
To: Some Recipient <[email protected]>
Subject: Saying Hello
Date: Tue, 6 Jun 2023 04:15:06 -0100
Message-ID: <[email protected]>
This is a message just to say hello.
So, "Hello".
You can forward this to a email recipient using Google’s SMTP with
the following curl command provided you have a Google app
password:
$ curl --url 'smtps://smtp.gmail.com:465' --ssl-reqd \
--mail-from '[email protected]' \
--mail-rcpt '[email protected]' \
--upload-file mail.txt \
--user '[email protected]:your-gmail-app-password'
Output should be something like this:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12 0 0 100 12 0 10 0:00:01 0:00:01 --:--:-- 10
$
Mastodon Automated Postings using the API
You can post to Mastodon using their API using cURL.
Create or Find Your Access Token
Once you have a Mastodon account, you need your account's access token. The steps you need to get that:
- Sign into your Mastodon account
- Click on In the
"Preferences"link. - On the bottom left corner of that page, click the
"Development"link. - On the
"Your Applications"page, click the blueNEW APPLICATIONbutton. - Give your application a name, and decide what kind of access you want to have when you connect to your account via the Mastodon API (i
read,write, andfolloware the defaults). You can always change this later. - At the bottom of the page, click the blue
SUBMITbutton. - You will be directed back to the
Your applicationspage, but now you should see your application name. Click that. - In your application's page, there are three tokens. For this tutorial, you need the
Your access tokenone. Note: if your access token is ever compromised, you can click regenerate, and your old access token will stop working, and you'll be shown a new one.
Post a Status Update using cURL
$ curl https://mastodon.sdf.org/api/v1/statuses -H 'Authorization: Bearer put-your-api-token-here' -F 'status=Hello, World'