Testing domains using command line utilities

After you create a domain and activate your service configuration, we recommend testing that domain with either the web interface or command line utilities we provide to help you identify DNS issues or problems with your Fastly configuration. This guide focuses on using the command line utilities for that testing and covers how to:

  1. find the IP address of a Fastly POP
  2. add a domain Host entry to your hosts file
  3. test the domain in a web browser
TIP

If you don't want to use the command line utilities to test your domain, you can use the web interface to point to Fastly and test whether or not your configuration is working.

Before you begin

This guide assumes you've created a domain.

Determining the IP address of a Fastly POP

Use the host, nslookup, or dig command to determine the IP address of a Fastly POP. You'll use this information to temporarily modify your hosts file in order to test things properly. We return different IP addresses depending on the location and state of the network making the request. As a result, the IP address you receive for any specific query may differ from the below examples but should result in the best performance for you.

TIP

For non-TLS requests, use dualstack.nonssl.global.fastly.net for connection over IPv6. For TLS requests, use the custom TLS CNAME record provided in the web interface or by Fastly support. For more information about the Fastly TLS service, see our guide on TLS service options.

Running host for your domain returns both IPv4 addresses and IPv6 addresses:

$ host www.example.com.
www.example.com.is an alias for dualstack.nonssl.global.fastly.net.
dualstack.nonssl.global.fastly.net has address 199.232.144.204
dualstack.nonssl.global.fastly.net has IPv6 address 2a04:4e42:64::204

In this example, the IPv4 address is 199.232.144.204 and the IPv6 address is 2a04:4e42:64::204.

Running nslookup for dualstack.nonssl.global.fastly.net also returns both IPv4 addresses and IPv6 addresses:

$ nslookup dualstack.nonssl.global.fastly.net.
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: dualstack.nonssl.global.fastly.net
Address: 199.232.144.204
Name: dualstack.nonssl.global.fastly.net
Address: 2a04:4e42:64::204

In this example, the IPv4 address is 199.232.144.204 and the IPv6 address is 2a04:4e42:64::204.

Alternatively, you can run dig to determine the IP address, but you must specify an A query for IPv4 addresses or a AAAA query for IPv6 addresses.

Running dig for your domain with an A query returns:

$ dig +noall +answer -t A www.example.com.
www.example.com. 3600 IN CNAME dualstack.nonssl.global.fastly.net.
dualstack.nonssl.global.fastly.net. 30 IN A 199.232.144.204

The IPv4 address is 199.232.144.204

Running dig for your domain with an AAAA query returns:

$ dig +noall +answer -t AAAA www.example.com.
www.example.com. 3600 IN CNAME dualstack.nonssl.global.fastly.net.
dualstack.nonssl.global.fastly.net. 30 IN AAAA 2a04:4e42:64::204

The IPv6 address is 2a04:4e42:64::204.

Modifying your hosts file

Using the IP address determined above, temporarily add a static IP address and domain Host entry to the hosts file on your computer. Once you make this temporary change test your domain to prove that traffic is flowing the right way.

Use the following anycast IPs for testing your sites served over dualstack.nonssl.global.fastly.net.

IPv4IPv6
151.101.0.2042a04:4e42::204
151.101.64.2042a04:4e42:200::204
151.101.128.2042a04:4e42:400::204
151.101.192.2042a04:4e42:600::204

For example, if the domain you are testing is www.example.com and you are using the anycast IPv4 example 151.101.0.204, you would add this entry to the file and save the changes:

151.101.0.204 www.example.com
TIP

On machines running macOS or Linux, your hosts file is /etc/hosts. On Windows-based machines, it's C:\Windows\System32\Drivers\etc\hosts.

Testing your domain

Now that you've modified your host file, test your domain to make sure it's being pulled through Fastly's network. To test your domain, restart your browser then enter your domain in the address field. You should now see the updated domain in the address field indicating requests are being sent to the Fastly POP.

Alternatively, you can test the domain using a ping command to verify that your domain is being served by a Fastly POP address. In this case, ping www.example.com would display the Fastly POP address 151.101.56.204.

IMPORTANT

Be sure to remove the Host entry from your hosts file after you make CNAME changes to point your domain to Fastly.

What's next

When you're ready to route production traffic through Fastly, update your domain's CNAME record to begin routing client traffic through Fastly services instead of directly to your origin.

Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.