How do I get my IP address from the command line?

This would return to you your public IP

dig TXT +short

You mean whatever routable IP your dsl/cable modem/etc. router has?

You need to either query that device OR ask an outside server what IP it sees when you connect to it. The easiest way of doing that is to search google for "what is my ip" and like the calculation searches, it will tell you in the first search result. If you want to do it from the command line, you'll need to check the output of some script out there that will echo out the information. The dynamic dns service has one that you can use - try this command

wget -O -

You should get something like

HTTP request sent, awaiting response... 200 OK
Length: 105 [text/html]
Saving to: ‘STDOUT’

-                     0%[                    ]       0  --.-KB/s               <html><head><title>Current IP Check</title></head><body>Current IP Address:</body></html>
-                   100%[===================>]     105  --.-KB/s    in 0s      

2017-09-20 14:16:00 (15.4 MB/s) - written to stdout [105/105]

I've changed the IP in mine to a generic non-routable and bolded it for you.

If you want just the IP, you'll need to parse it out of there - quick and dirty, but it works for me. And I'm 100% sure there is a better safer way of doing it...

wget -O - | grep IP | cut -f 2- -d : | cut -f 1 -d \<

Which will give you just

Alternatives (avoid parsing):

To get the IPv4

curl -4

To get the IPv6

curl -6