The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,839 other subscribers

Getting your public IP address from the command-line when http and https are blocked: use DNS

Posted by jpluimers on 2022/12/28

Years ago, I wrote Getting your public IP address from the command-line. All methods were http based, so were very easy to execute using cURL.

But then in autumn 2021, Chris Bensen wrote this cool little blog-post [Wayback/Archive] Chris Bensen: How do I find my router’s public IP Address from the command line?:

dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com

At first sight, I thought it was uncool, as the command was quite long and there was no explanation of the dig command trick.

But then, knowing that dig is a DNS client, it occurred to me: this perfectly works when http and https are disabled by your firewall, but the DNS protocol works and gives the correct result:

# dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
"80.100.143.119"

This added the below commands and aliases to my tool chest for *nix based environments like Linux and MacOS (not sure yet about Windows yet :), but that still doesn’t explain why it worked. So I did some digging…

IPv4

  • command:
    dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
  • command removing outer double quotes:
    dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | xargs
  • alias:
    alias "whatismyipv4_dns=dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | xargs"

IPv6

  • command:
    dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com
  • command removing outer double quotes:
    dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com | xargs
  • alias:
    alias "whatismyipv6_dns=dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com | xargs"

How it works

Let’s stick to dig and IPv4 as that not having IPv6 (regrettably still) is the most common situation today:

# dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
"80.100.143.119"

What it does is request the DNS TXT record of o-o.myaddr.l.google.com from the Google DNS server ns1.google.com and returns the WAN IPv4 address used in the DNS request, which is for instance explained in [Wayback/Archive] What is the mechanics behind “dig TXT o-o.myaddr.l.google.com @ns1.google.com” : linuxadmin.

Since these are TXT records, dig will automatically double quote them, which xargs can remove (see below how and why):

# dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | xargs
80.100.143.119

The DNS query will fail when requesting the Google Public DNS servers 8.8.8.8 or 8.8.4.4:

# dig -4 TXT +short o-o.myaddr.l.google.com @8.8.8.8
"2a00:1450:4013:c1a::103"
"edns0-client-subnet 80.101.239.0/24"

Or, with quotes removed (the -L 1 ensures that xargs performs the quote-pair removal action on each line):

# dig -4 TXT +short o-o.myaddr.l.google.com @8.8.8.8 | xargs -L 1
2a00:1450:4013:c1a::103
edns0-client-subnet 80.101.239.0/24

This request is both slower than requesting the ns1.google.com server and wrong.

The reason is that only ns1.google.com understands the special o-o.myaddr.l.google.com hostname which instructs it to return the IP address of the requesting dig DNS client.

That 8.8.8.8 returns a different IP address and an additional edns0-client-subnet with less accurate information is explained in an answer to [Wayback/Archive] linux – Getting the WAN IP: difference between HTTP and DNS – Stack Overflow by [Wayback/Archive] argaz referring to this cool post: [Wayback/Archive] Which CDNs support edns-client-subnet? – CDN Planet.

Not just ns1.google.com: any DNS server serving the google.com domain

Since o-o.myaddr.l.google.com is part of the google.com domain, the above works for any DNS server serving the google.com domain (more on that domain: [Wayback/Archive] General DNS overview  |  Google Cloud).

Getting the list of DNS servers is similar to getting the list of MX servers which I explained in Getting the IP addresses of gmail MX servers, replacing MX record type (main exchange) with the NS record type (name server) and the gmail.com domain with the google.com domain:

# dig @8.8.8.8 +short NS google.com
ns3.google.com.
ns1.google.com.
ns2.google.com.
ns4.google.com.

The ns1.google.com DNS server is a special one of the NS servers: it is the start of authority server, which you can query using the SOA record type that also gives slightly more details for this server:

# dig @8.8.8.8 +short SOA google.com
ns1.google.com. dns-admin.google.com. 410477869 900 900 1800 60

The difference between using NS and SOA records with dig are explained in the [Wayback] dns – How do I find the authoritative name-server for a domain name? – Stack Overflow answer by [Wayback/Archive] bortzmeyer who also explains how to help figuring out SOA and NS discrepancies (note to self: check out the check_soa tool originally by Michael Fuhr (I could not find recent content of him, so he might have passed away) of which source code is now at [Wayback/Archive] Net-DNS/check_soa at master · NLnetLabs/Net-DNS).

So this works splendid as well using ns4.google.com on my test system:

# dig -4 TXT +short o-o.myaddr.l.google.com @ns4.google.com | xargs
80.100.143.119

The xargs removes outer quotes removal trick

[Wayback/Archive] string – Shell script – remove first and last quote (“) from a variable – Stack Overflow (thanks quite anonymous [Wayback/Archive] user1587520):

> echo '"quoted"' | xargs
quoted

xargs uses echo as the default command if no command is provided and strips quotes from the input.

More on https versus DNS requests

Some notes are in [Wayback/Archive] How to get public IP address from Linux shell, but note the telnet trick now fails as myip.gelma.net is gone (latest live version was archived in the Wayback Machine in august 2019).

Via

–jeroen

Posted in *nix, *nix-tools, Apple, bash, bash, Batch-Files, Communications Development, Development, DNS, Internet protocol suite, Linux, Mac, Mac OS X / OS X / MacOS, Power User, Scripting, Software Development, TCP | Leave a Comment »

Kevlin Henney on Twitter: “#FizzBuzzFriday… ” Python table lookup versus C# functional programming

Posted by jpluimers on 2022/12/27

[Archive.is] Kevlin Henney on Twitter: “#FizzBuzzFriday… “.

Related: [Wayback] Your C# is already functional, but only if you let it | In Absentia:

A few days ago I tweeted a C# code snippet, showing a FizzBuzz implementation using some of the new features in C# 8.0. The tweet “went viral”, as the kids say, with several people admiring the terse

–jeroen

Read the rest of this entry »

Posted in .NET, C#, Development, Functional Programming, Python, Software Development | Leave a Comment »

Finding your Google Pay payments and receipts (they do not send proper invoices)

Posted by jpluimers on 2022/12/26

For my link archive: [WayBack/Archive.is] Your Google Store charges and receipts – Google Store Help

Charges:

  1. Visit pay.google.com/.
  2. Sign in to your Google account.
  3. On the left, click Subscriptions and services.
  4. Click View purchases.

Receipts and order numbers

  1. Visit pay.google.com/ and sign in with your Google account.
  2. On the left, click Subscriptions and services.
  3. Click View purchases.
  4. Select an order to see your receipt.
    • If you need your order number, you can find it on the receipt page.

VAT invoice

If you live in the European Union, Switzerland, or Norway, learn how to request a VAT invoice:

You can request each month’s invoice in the first few days of the following month. It might take up to 24 hours to process your request.

The address shown on your VAT invoice is your legal address at the time the purchase was made. You can’t change the address that appears on a VAT invoice after the purchase is made.

  1. Sign in to Settings.
  2. Check that you’ve entered your tax ID number. If you haven’t, enter it now.
    • In some countries, you can’t get a VAT invoice if you didn’t enter your tax ID number before you made the purchase.
  3. Click Activity.
  4. Click on the transaction you want an invoice for.
  5. At the bottom of the transaction details, click Download VAT invoice. You may be asked to enter some information, like your full address or a tax ID.
  6. Click Save. You’ll see a link where you can download your invoice.

 

 

 

 

 

–jeroen

Posted in Google, GooglePay, Power User | Leave a Comment »

Terry Hughes on Twitter: “I think of this image every time some journalist complains about climate change protesters disrupting traffic…..… “

Posted by jpluimers on 2022/12/23

[Archive] Terry Hughes on Twitter: “I think of this image every time some journalist complains about climate change protesters disrupting traffic…..… “

The oldest version of this image I could find back were dated 20210717:

–jeroen

Read the rest of this entry »

Posted in Awareness | Leave a Comment »

Web issues are either DNS or caching

Posted by jpluimers on 2022/12/22

I can relate to both DNS and caching posts:

–jeroen

Read the rest of this entry »

Posted in Development, DevOps, Infrastructure, Power User | Leave a Comment »

SimenHolmestad/Privacynator: A utility for removing Personally Identifiable Information (PII) from videos.

Posted by jpluimers on 2022/12/21

[Archive] SimenHolmestad/Privacynator: A utility for removing Personally Identifiable Information (PII) from videos.

Privacynator is an utility for removing Personally Identifiable Information (PII) from videos. It is primarily meant for videos captured from cars.
Privacynator uses the Detectron2 model from facebook research: https://github.com/facebookresearch/detectron2.

It is written in Python 3.

It is unlike this: Need to check if “PrivacyNator” is already out: a local TensorFlowJS app that blurs your screen when you are not behind it

–jeroen

Posted in Development, Python, Scripting, Software Development | Leave a Comment »

Securely Connecting to Autonomous DB Without a Wallet (Using TLS)

Posted by jpluimers on 2022/12/20

[Wayback/Archive] Securely Connecting to Autonomous DB Without a Wallet (Using TLS)

It is about moving from mTLS to TLS on Oracle Autonomous DB and at the same time IP-whitelisting the client IP addresses.

[Archive] Chris Bensen on Twitter: “This is extremely useful so I figured I’d share in the hopes it helps someone else “

–jeroen

Posted in Cloud, Cloud Development, Database Development, Development, Infrastructure, OracleDB, Software Development | Leave a Comment »

Some links to poaching eggs

Posted by jpluimers on 2022/12/19

I never knew poaching of eggs is so easy!

  • no vinegar
  • no salt
  • no stirring
  • no thermometer
  • no poacher

Just a frying pan with 4cm water that is not boiling, a ladle spoon, a large kitchen sieve, and fresh eggs will do; for each egg:

  • empty it in the ladle spoon
  • gently drop the ladle spoon content in an empty spot in the water
  • let the egg white stiffen for 3-4 minutes
  • pull it out with the kitchen sieve when done

So here are some links:

–jeroen

Read the rest of this entry »

Posted in Cooking, LifeHacker, Power User | Leave a Comment »

Space Karen Sucks

Posted by jpluimers on 2022/12/18

https://spacekaren.sucks/

Free speech really should be free. To bypass the new censorship regime at twitter, use this URL shortener to link to Mastodon or other censored destinations

Jack didn’t understand the new rules either:

–jeroen

Posted in Uncategorized | Leave a Comment »

The circadian immune system: A recent @SciImmunology Review highlights the benefits of morning vaccination compared with afternoon/evening vaccination in humans.

Posted by jpluimers on 2022/12/18

Paper: [Wayback/Archive] The circadian immune system

Abstract

The immune system is highly time-of-day dependent. Pioneering studies in the 1960s were the first to identify immune responses to be under a circadian control. Only in the last decade, however, have the molecular factors governing circadian immune rhythms been identified. These studies have revealed a highly complex picture of the interconnectivity of rhythmicity within immune cells with that of their environment. Here, we provide a global overview of the circadian immune system, focusing on recent advances in the rapidly expanding field of circadian immunology.

Image from [Wayback/Archive] Science Magazine on Twitter: “A recent @SciImmunology Review highlights the benefits of morning vaccination compared with afternoon/evening vaccination in humans. Learn more: “

Read the rest of this entry »

Posted in Health, LifeHacker, Power User | Leave a Comment »