Software DNS

I am a long time developer, but not very experienced with DNS. Here is my problem:

Our application runs servers on Amazon EC2 for customers. One client wants to use its own DNS for each running server instead of the usual long public DNS provided by AWS: for example, server-5.demo.ourclient.com, server-6.demo.ourclient.com.

What is the easiest / cleanest / best way to solve this problem inside our application, which runs servers and knows Amazon's public DNS? Perhaps we will also gain control of demo.ourclient.com.

Are there any good hosting solutions with API? Do we need to manage a DNS server for * .demo.ourclient.com?

Thanks!

Chad

+4
source share
4 answers

You can try one of the dynamic dns services. They let you define your own hostnames, such as machine1.dyndns.org, and attach them to the IP address. There are scripts that you can run to update the dyndns permission with the dynamic IP address provided by EC2.

+2
source

Even better would be to use Route53, which is Amazon's dynamic DNS service: http://aws.amazon.com/documentation/route53/

+3
source

I really don’t understand why your client will not use Elastic IP or Elastic Load Balancer here?

With Elastic IP, you can save a consistent name in your public DNS record, and then manually or programmatically update the EC2 instance associated with this EIP when necessary using the elb API scripts.

By balancing the elastic load, you can easily connect only one active node to the ELB, and then programmatically remove / add nodes and update Route53 accordingly.

You can use the internal machine API to get the values ​​(Instance ID, etc.) for these calls in boostrap script.

0
source

This code gets your ip and then sets it to route53. You must specify the variables DOMAIN and HOSTED_ZONE_ID. You can run this at startup. If you do not want to rely on ifconfig.co, instead

DOMAIN="desired.domain.com" HOSTED_ZONE_ID="..." # ANYWHERE, but relies on ifconfig.co MYIP=$(curl -s ifconfig.co) # ON EC2: MYIP=$(curl -s curl 169.254.169.254/latest/meta-data/public-ipv4) # create json to send to route53 cat > /tmp/actual_ip.json <<EOF { "Comment": "Update the A record set", "Changes": [ { "Action": "UPSERT", "ResourceRecordSet": { "Name": "$DOMAIN", "Type": "A", "TTL": 300, "ResourceRecords": [ { "Value": "$MYIP" } ] } } ] } EOF # update the dns entry if ! /usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/actual_ip.json; then echo "error calling aws $?" fi 
0
source

Source: https://habr.com/ru/post/1304962/


All Articles