Theodore Baschak

BOFH. Open Source Guru. Founder/Operator of Hextet Systems, AS395089 and Network Architect for Daemon Defense Systems, AS55101.

ipquail now curl friendly

Sat, 05 Jul 2014 13:56:04 -0500 » Anycast, Nerd Projects, CLI, IPv6, Programming, SaltStack, System Administration

I’ve always liked how the site ifconfig.me (down today it seems) returns JUST the IP address from command line when accessed via CURL. Unfortunately it is not IPv6 enabled. This morning I set out to CLI-enable ipquail.com. The journey is documented in this short commit history.

$ for i in www 4 6; do \
  echo -n "curl $i.ipquail.com => "
  curl $i.ipquail.com
  done
curl www.ipquail.com => 2604:4280:d000:11::5
curl 4.ipquail.com => 199.202.21.5
curl 6.ipquail.com => 2604:4280:d000:11::5

This can be used in scripts as well:

#!/bin/bash

IP4=`curl 4.ipquail.com 2>/dev/null`
IP6=`curl 6.ipquail.com 2>/dev/null`

echo "Your IP Address is $IP4"
echo "Your IPv6 Address is $IP6"

I deployed the new files to all Anycast nodes using SaltStack as described in my previous post.

Note: This only works if you are NOT changing the default curl user agent, if you are, you would need to specify curl as your user agent using the -A flag for curl.

© Theodore Baschak - https://github.com/tbaschak - Powered by Jekyll.
Powered by Les.net.
CiscoDude.net is a personal website. Opinions expressed are not necessarily those of his employer.