I have a custom Domain Name System (DNS) server. How do I mount an Amazon Elastic File System (Amazon EFS) system using a DNS name?

You can mount an Amazon EFS on an Amazon Elastic Compute Cloud (Amazon EC2) instance using a DNS name for the file system. To do so, the following must be true:

The connecting EC2 instance must be inside a virtual private cloud (VPC), and it must be configured to use the custom DNS server. For information about Amazon DNS server, see DHCP Options Sets.

The DNS settings DNS resolution and DNS hostnames are enabled in your custom VPC. For more information, see Updating DNS Support for Your VPC.

Note: Amazon EFS file systems can be mounted only on Linux EC2 instances.

Using a Windows DNS server

1.    From the VPC console, choose Your VPCs from the left navigation pane, choose the desired VPC, and then choose the Summary tab. Take note of the IPv4 CIDR address.

2.    In EC2-VPC, the Amazon DNS server is located at the base of your VPC network range plus two, so choose one of these IPv4 addresses. For more information, see Amazon DNS Server.

3.    Add a conditional forwarder in your Windows DNS server using the dnscmd command, the /zoneadd and /forwarder parameters, and the IP address from step one. In this example, the IP address is 172.31.0.2, which is the second valid IPv4 address for a subnet with an address of 172.31.0.0/16:

C:\Windows\system32> dnscmd  /ZoneAdd amazonaws.com /forwarder 172.31.0.2

The conditional forwarder handles the DNS requests from the amazonaws.com domain to your Windows VPC DNS server. This allows DNS queries from EC2 instances to be forwarded to the Amazon DNS server that can translate the Amazon EFS DNS name.

4.    Use the nslookup command and your Amazon EFS file system ID to validate that the Windows DNS server is resolving the DNS queries. Run the following command in your Windows DNS server:

C:\Windows\system32>nslookup file-system-id.efs.aws-region.amazonaws.com

Note: To find the Amazon EFS file system ID, first open the Amazon EFS Management Console, and then choose File systems from the left navigation pane.

Using an Ubuntu DNS server

1.    Install bind9 and bind9utils:

$ sudo apt-get update
$ sudo apt-get install bind9 bind9utils

2.    Configure Bind9 as a caching DNS server, and then forward the domain amazonaws.com to your VPC DNS server.

3.    Open and modify the named.conf.options file:  

$ sudo nano /etc/bind/named.conf.options

Note: The following example shows the minimum configuration. You can append these options to your existing named.conf.options config file.

The IP address must be the IPv4 private IP of the Amazon DNS Server, and the first IP address of the subnet from the VPC where that Amazon EFS file system was created. In this example, we're using 172.31.0.2 as the IP address, and 172.31.0.0/16 as the CIDR:  

options {
    directory "/var/cache/bind";
    forwarders { 172.31.0.2; };
    allow-query { 172.31.0.0/16; };

    forward only;
    dnssec-validation no;
    dnssec-enable no;
    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};
zone "amazonaws.com" IN {
      type forward;
      forward first;
      forwarders { 172.31.0.2; };
};

4.    Restart Bind9 to apply the new configuration:

$ sudo systemctl restart bind9

5.    Use the dig command to make a DNS query using your Amazon EFS file system ID to confirm that the Linux DNS server is resolving the DNS queries:

$ dig +short file-system-id.efs.aws-region.amazonaws.com @172.31.0.2

6.    Install the nfs-utils and nfs-common packages so that you can mount the Amazon EFS:

$ sudo yum install nfs-utils -y || sudo apt-get install nfs-common -y

The yum command is used for Amazon Linux, CentOS, or RHEL. The apt-get command is used for Debian-based Linux distributions such Ubuntu.

7.    Mount the Amazon EFS into your Linux instance:

$ mkdir /mnt/efs; mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.efs.aws-region.amazonaws.com:/ /mnt/efs

For more information, see Additional Mounting Considerations.


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-09-26