Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve DNS name of EFS while mounting it on red hat ec2 instances using putty

I am having an issue where I am unable to mount my EFS on red hat ec2 instance using the DNS names. It throws the error

mount.nfs4: Failed to resolve server us-east-1a.fs-c2aXXXX.efs.us-east-1.amazon
aws.com: Name or service not known

I am following the instructions provided by AWS. I tried below two ways to do it and both throw the same above error. I can confirm that the DNS names are correct.

1st:

mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-c2aXXXX.efs.us-east-1.amazonaws.com:/ efs

2nd:

mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).fs-c2a7XXXX.efs.us-east-1.amazonaws.com:/ /efs

However, if I use IP instead of DNS names, I am able to mount it just fine. So below command works.

mount -t nfs4 -o 
nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.38.X.XX:/ /efs

I am fine with using IP instead of DNS as long as I am able to mount it.

Now my issue is as soon as I stop and start the instance again, my mount is gone. Even after I add the below entry to the /etc/fstab, it doesn't do auto mount.

10.38.X.XXX:/ /efs efs defaults,_netdev 0 0

Can someone please help me in either resolving the issue with DNS or tell me how to auto mount using IPs?

like image 305
Naxi Avatar asked Oct 26 '18 14:10

Naxi


2 Answers

To attach to EFS from the command line use this as your template, replacing fs-12345678 with your id:

$ sudo mount -t efs fs-12345678:/ /efs

Use this in your /etc/fstab (do not add .efs.us-east-1.amazonaws.com after it)

fs-12345678:/ /efs efs vers=4.1,rw,tls,_netdev,relatime,acl,nofail 0 0

The fstab version also turns on encryption for data transport. Check out the resource for more information

Resources

https://docs.aws.amazon.com/efs/latest/ug/mounting-fs.html https://docs.aws.amazon.com/efs/latest/ug/troubleshooting-efs-mounting.html#automount-fails

like image 56
kenlukas Avatar answered Sep 20 '22 07:09

kenlukas


If you have opened all security groups, network ACLs, confirmed that you are in a valid AZ and still not working; probably the VPC you created doesn't have DNS hostnames enabled, validate that you have this setting:

vpc

The default VPC that comes with your account has this enabled, others don't.

like image 39
Luigi Lopez Avatar answered Sep 24 '22 07:09

Luigi Lopez