All Products
Search
Document Center

Function Compute:Configure custom DNS

Last Updated:Mar 23, 2026

You can use Custom DNS for scenarios such as accelerating site access. This topic describes how to configure Custom DNS for a function in the Function Compute console.

Background information

The resolv.conf file is a system configuration file. After you configure custom DNS, the existing resolv.conf file is overwritten. You can view the specifications of the resolv.conf file by running the man 5 resolver command on a Linux system. If the man page is not found, install it based on your distribution. For more information, see Linux manual page.

Limitations

The Custom DNS feature does not support Custom Image.

Prerequisites

You have created a function, excluding GPU-accelerated functions.

Configure DNS

Note

To use the default DNS server of Function Compute, add the default IP addresses 100.100.2.136 and 100.100.2.138 to Name Servers.

  1. Log on to the Function Compute console. In the left-side navigation pane, choose Function Management > Function.

  2. In the top navigation bar, select a Region. On the Function page, click the target function.

  3. On the function details page, click the Configuration tab. To the right of Advanced Settings, click Modify. In the Advanced Settings panel, find the DNS section, configure the following parameters, and click Deploy.

    Parameter

    Description

    Example

    Name Servers

    Specifies the IP addresses of the DNS servers. You can add multiple addresses.

    • 223.5.5.5

    • 223.6.6.6

    Search Domain

    A DNS search domain. You can add multiple search domains. If a domain name fails to resolve, the system appends a search domain and retries the query.

    example.com

    DNS Options

    Each configuration item in the resolv.conf file is a key-value pair in the key:value format, where the key is required.

    attempts:1

  4. Verify that the Custom DNS settings are effective.

    1. On the function details page, click the Code tab.

    2. In the code editor, write your code, click Deploy, and then click Test Function.

      Sample code (Python 3):

      import logging
      import subprocess
      
      def handler(event, context):
        logger = logging.getLogger()
        f = open('/etc/resolv.conf')
        logger.info("".join(f.readlines()))
        f.close()
        output = subprocess.check_output(["ping", "-c", "1", "www.aliyun.com"])
        return output
    3. On the Code tab, view the execution result: in the Response area, view the content generated for resolv.conf, and in the Log Output area, view the IP address of the returned domain name.