Easy Ngrok with Docker

If you are using localhost as a development platform, you are probably aware of ngrok. You might have installed it in your machine, along with some dependencies. While I have focused on stateless development machine, it is important for me and developers like me to have everything portable. Now I have ngrok portable with a simple alias:

function expose-ngrok() {
  docker run --rm --net=host -e NGROK_PORT="$1" wernight/ngrok
}

Then navigate to localhost:4040 to find the url assigned to you.

Tell your network!

How to Get Public IP Address in Linux

Problem with WGET/CURL

You might have a seen a lot of wget/curl related way to get an IP address. One of my clients was using it and it looks like somehow he was blocked. Now it might have not been the case if he was spoofing but assume that he would get blocked eventually, I used dig with opendns (over Google).

Blocking isn’t one way – may be the service is down – it happened to us all isn’t it?

With dig, system is running for a year and my Client hired me for another project and asked me how I did it. So I thought I should share it to readers as well.

Most Reliable way is through dig

dig +short myip.opendns.com @resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'

A little less reliable way is through host

host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'

Tell your network!