Updated on 2024-03-14 GMT+08:00

Routing Internet Traffic to a Website

Scenario

After you register a domain name and set up a website, you can configure record sets to map the domain name to the public IP address of the web server so that end users can use the domain name to access your website over the Internet.

For example, you have already built a website on a web server with a public IPv4 address bound. To allow end users to access your website using domain name example.com and its subdomain www.example.com, perform the following operations:

  • Add an A record set that maps domain name example.com to the public IP address of the web server.
  • Add an A record set that maps subdomain www.example.com to the public IP address of the web server.

Prerequisites

  • You have registered domain name example.com.
  • You have deployed a web server and obtained its public IP address.

Process Flow

Figure 1 shows the process for configuring a domain name for your website.

Figure 1 Process for configuring a domain name

Procedure

  1. Create a public zone.

    Create a public zone for your domain name on the DNS console.

    1. Log in to the management console.
    2. In the service list, choose Network > Domain Name Service.

      The DNS console is displayed.

    3. In the navigation pane on the left, choose Public Zones.

      The Public Zones page is displayed.

    4. Click Create Public Zone.
    5. Set Domain Name to example.com.

      Configure other parameters by referring to Creating a Public Zone.

    6. Click OK.

      You can view the created public zone on the Public Zones page.

      You can click the domain name to view SOA and NS record sets automatically generated for the zone.

      • The NS record set defines the authoritative DNS servers for the domain name.
      • The SOA record set identifies the primary authoritative server for the domain name.

  1. Add an A record set to the second-level domain name.

    Add an A record set to the created public zone to allow access to your website using example.com.
    1. On the Public Zones page, click the domain name (example.com) of the public zone you created.

      The Record Sets page is displayed.

    2. Click Add Record Set.
    3. Configure the parameters as follows:
      • Name: Leave this parameter blank. The DNS service automatically considers example.com as the name, and requests are routed to example.com.
      • Type: Retain the default setting A – Map domains to IPv4 addresses.
      • Value: Enter the public IP address of your web server.

      Configure other parameters by referring to Adding an A Record Set.

    4. Click OK.

      You can view the added record set in the Normal state.

  2. Add an A record set to a subdomain.

    Add another A record set to the created public zone to allow access to your website using www.example.com.

    1. On the Public Zones page, click the domain name (example.com) of the public zone you created.

      The Record Sets page is displayed.

    2. Click Add Record Set.
    3. Configure the parameters as follows:
      • Name: Set it to www, indicating that the subdomain to be resolved is www.example.com.
      • Type: Retain the default setting A – Map domains to IPv4 addresses.
      • Value: Enter the public IP address of your web server.

      Configure other parameters by referring to Adding an A Record Set.

    4. Click OK.

      You can view the added record set in the Normal state.

  1. Change the DNS server addresses.

    The DNS service provides authoritative DNS servers for domain resolution.

    After you create a public zone, an NS record set is generated, which specifies the DNS servers provided by the DNS service.

    If DNS server addresses of the public domain name are not the same as those in the NS record set, the DNS service will not be able to resolve the domain name. You must change the DNS server addresses of the domain name on the registrar's website.

    Generally, the changes to DNS server addresses take effect within 48 hours, but the time may vary depending on the domain name registrar's cache duration.

    Query the DNS server addresses provided by the DNS service.

    1. Log in to the management console.
    2. In the service list, choose Network > Domain Name Service.

      The DNS console is displayed.

    3. In the navigation pane on the left, choose Public Zones.

      The Public Zones page is displayed.

    4. Click the domain name of the public zone you created.

      Locate the NS record set and view the DNS server addresses under Value.

    Change the DNS servers.

    Log in to the domain name registrar's website and change the DNS server addresses to those provided by the DNS service. Refer to the domain name registrar's documentation for detailed operations.