A command line utility to locate an Akamai Staging network IP address for one or more domains
npm install akamai-stagingnpm install -g akamai-staging
staging [domain]
hosts file
hosts file format.
hosts file entry which resolves the domain to an IP address in Akamai's Staging network.
npm install -g akamai-staging
staging domain [domain [domain] ...]
staging www.akamai.com
bash
C:\> staging www.akamai.com
104.82.168.181 www.akamai.com #Akamai Staging variant of [www.akamai.com.edgekey.net]
`
!A single domain
$3
If your front-end consists of multiple domains, you may need to point more than one to the Staging network. You can pass multiple domains, separated by spaces, via the command line:
staging www.asos.com api.asos.com my.asos.com
`bash
C:\> staging www.asos.com api.asos.com my.asos.com
23.50.57.68 www.asos.com #Akamai Staging variant of [snir.www.asos.com.v4.edgekey.net]
23.50.57.240 api.asos.com #Akamai Staging variant of [snir.asos.com.v4.edgekey.net]
23.50.57.68 my.asos.com #Akamai Staging variant of [snir.www.asos.com.v4.edgekey.net]
`
!Multiple domains
$3
Why not redirect stdout to append the hosts file, seeing as you're going to need these entries in there anyway.
NB you may have flush your O/S's resolver cache, and flush your browser DNS cache before new hosts entry is recognised
#### Windows (as local admin)
⚠ Make sure you use a double greater-than redirect >> to append to the target file; using only one will replace the target file and nuke your current hosts file.
C:\> staging www.akamai.com >> %systemroot%\system32\drivers\etc\hosts
C:\> type %systemroot%\system32\drivers\etc\hosts
`text
Copyright (c) 1993-2009 Microsoft Corp.
#
This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
This file contains the mappings of IP addresses to host names. Each
entry should be kept on an individual line. The IP address should
be placed in the first column followed by the corresponding host name.
The IP address and the host name should be separated by at least one
space.
#
Additionally, comments (such as these) may be inserted on individual
lines or following the machine name denoted by a '#' symbol.
#
For example:
#
102.54.94.97 rhino.acme.com # source server
38.25.63.10 x.acme.com # x client host
localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
23.195.136.39 www.akamai.com #Akamai Staging variant of [www.akamai.com.edgekey.net]
`
#### Linux (as root)
#### Error reporting and redirection / piping
All hosts file entries and staging IP addresses are output to stdout while all errors are output to stderr.
This means that if you use the redirection approach above, successful staging IP lookups will be written to the target file while errors appear in the console.
!Redirect to a file
You can redirect them individually by using the notation 1> to direct stdout and 2> to redirect stderr somewhere else.
Note: All errors are printed with a preceding hash character #, which denotes a comment in the hosts file. So, if you wish, you could redirect both stdout and stderr to the target file without it compromising the hosts file structure.
$ sudo staging www.akamai.com >> /etc/hosts
$ cat /etc/hosts
`bash
127.0.0.1 localhost
The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
23.195.136.39 www.akamai.com #Akamai Staging variant of [www.akamai.com.edgekey.net]
`
---
Debugging
akamai-staging uses the npm package debug. If you set the environment variable debug to staging you'll see full debug output.
$3
`bash
set debug=staging
staging [domain]
`
$3
`bash
DEBUG=staging staging [domain]
`
$3
`bash
$env:debug="staging"
node akamai-staging [domain]
`
---
Restrictions
$3
DNS standards do not allow a CNAME record in the apex (A or AAAA are the only allowed record types), and DNS providers get around this in proprietary ways. The use of dns.resolveCname to get the initial alias of the hostname fails because it's not a CNAME record that's being returned.
---
Change Log
The CHANGELOG.md` can be found here