edit-icon download-icon

Modify local hosts file to test WAF

Last Updated: Feb 05, 2018

Location of hosts file

C:\Windows\System32\drivers\etc\hosts

Hosts file functionality

The hosts file specifies the correspondence between the domain name and IP address. If a domain name has an IP address specified in the hosts file, the system will not resolve its IP address through the domain name system (DNS) when accessing this domain name, but will directly access the specified IP address instead.

Therefore, if your website is deployed with Anti-DDoS Pro or WAF services, you can modify the local hosts file to direct the website to the WAF without changing the online business flow. This allows you to test whether or not the business services work normally after they pass through WAF.

Procedure

  1. Find the IP address allocated by WAF.

    When the domain name is configured, WAF generates a CNAME record for resolution purposes. Use the ping command to get the IP address of the CNAME record, and this IP address is the WAF IP. Use www.abc.com as an example.

    1. Find the allocated CNAME record.

      Allocated CNAME record.

    2. Use the ping command to get the IP address of the CNAME record.

      Use Ping command to get the WAF IP

  2. Locate the C:\Windows\System32\drivers\etc\ folder.

  3. Open the hosts file in Notepad, and point the domain name to the WAF IP address.

    Note: The hosts file format is “<IP> <domain name>“. For example, point www.abc.com to xx.xx.xx.xxx.

    xx.xx.xx.xxx www.abc.com

  4. Save the modified hosts file to the C:\Windows\System32\drivers\etc\ folder.

Thank you! We've received your feedback.