Solved

how to set dns to allow the settings of TTL

Posted on 2011-09-27
19
486 Views
Last Modified: 2012-05-12
Hi,
I have a small issue regarding dns, I would like a attributes to set TTL's of record.
Thanks.
0
Comment
Question by:lionel3030
  • 10
  • 9
19 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714618
Setting TTL's for records should be very straight forward.

Which DNS server are you running?
0
 

Author Comment

by:lionel3030
ID: 36714658
Hi Papertrip,
I used Bind
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714668
OK cool, I know BIND very well so this should be quick and easy.

Your original question is a bit unclear, what exactly are you trying to do?  Do you need to change the TTL of an existing record?  Do you have questions about TTL in general?  Also, are you using dynamic zones?
0
 

Author Comment

by:lionel3030
ID: 36714686
Ok what i am trying to do is to learn how to set attribute to set the TTLs of records, its on chef for cloud recipes
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714697
I'm not familiar with Chef -- do you use that to administer your DNS zones, or do you update them manually?
0
 

Author Comment

by:lionel3030
ID: 36714701
I am trying to get chef to take all credentials for route53 (DNS) attributes from encrypted data bags thus updating the record from there.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714712
Unfortunately I have no experience with Chef.  I did some research on it and I know what it is now, so maybe I can still help you since the underlying server is running BIND.

How are you adding records to DNS via Chef now?  Any information about how you are using Chef + DNS will help a lot.
0
 

Author Comment

by:lionel3030
ID: 36714731
Using the following:
default[:route53][:zone_id] = "ZONE_ID"
default[:route53][:aws_access_key_id] = "KEY"
default[:route53][:aws_secret_access_key] = "SECRET"
So from here I am trying to get all this info in one place and give a attribute to set the TTL's, I have searched around to get this working but for some reason it's beyond me.
Thanks.
0
 

Author Comment

by:lionel3030
ID: 36714736
might be able to use something like # route53 add_record ZONEID db01.mycompanycloud.com CNAME ec2-51-10-11-89.compute-1.amazonaws.com 3600 but not sure it is going to give me exactly what i want.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 21

Expert Comment

by:Papertrip
ID: 36714753
OK I did some research on route53, and it looks like you are correct in your guess.

route53 add_record ZONEID db01.mycompanycloud.com CNAME ec2-51-10-11-89.compute-1.amazonaws.com 3600

Open in new window

After you run that, you can test at http://tools.whois.net/dig/  -- The 2nd field you see in the ANSWER SECTION is the TTL value of the record.

If this is a new record, you should see the results almost immediately.  If you are updating an existing record, and the DNS server you are querying still has a cached version of the old record, then your TTL changes will not be visible until the old TTL has expired.

Make sense?
0
 

Author Comment

by:lionel3030
ID: 36714770
Yep it does but 1 thing i dont have anything to do to set attributes?
0
 

Author Comment

by:lionel3030
ID: 36714777
maybe this might work as well?
aws_creds = Chef::EncryptedDataBagItem.load("aws", "#{node[:mycompany_vars][:customer_name]}_keys")
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714786
Do you mean setting the TTL in these attributes?

default[:route53][:zone_id] = "ZONE_ID"
default[:route53][:aws_access_key_id] = "KEY"
default[:route53][:aws_secret_access_key] = "SECRET"
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714796
So that part is getting into how Chef works, which I'm not familiar with.

However, I did find this:

Here's how you add a CNAME record with a TTL of 60 seconds to an existing zone (assuming the 'zone' variable contains the zone you're looking for). You need to operate on the zone ID, which is the identifier following the text '/hostedzone/' in the 'Id' field of the variable 'zone'.

from boto.route53.record import ResourceRecordSets
zone_id = zone['Id'].replace('/hostedzone/', '')
changes = ResourceRecordSets(conn, zone_id)
change = changes.add_change("CREATE", 'test2.%s' % ROUTE53_ZONE_NAME, "CNAME", 60)
change.add_value("some_other_name")
changes.commit()

Does that help with your attribute question?

http://agiletesting.blogspot.com/2011/06/managing-amazon-route-53-dns-with-boto.html
0
 

Author Comment

by:lionel3030
ID: 36714805
I meant to give attribute to set TTL in dns directly, i need to search a bit on your last message, I will update soon.
thanks for your help
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714842
0
 
LVL 21

Accepted Solution

by:
Papertrip earned 500 total points
ID: 36714843
Attribute Parameters:

    zone - DNS zone
    name - fully qualified domain name of entry in zone
    type - DNS record type (CNAME, A, etc)
    values - Record values.
    default_ttl - default time to live in seconds
    access_key - dyn username
    secret_key - dyn password

None of the parameters have default values.

Example:

route53_rr "webprod" do
  name       "webprod.#{node.route53.zone}"
  type "A"   values([ "10.1.1.10"])
  ttl        node[:route53][:default_ttl]
  access_key node[:route53][:access_key]
  secret_key node[:route53][:secret_key]
  zone       node[:route53][:zone]
end
0
 

Author Comment

by:lionel3030
ID: 36714880
thanks for all your help i will try to set theses lines into one if possible i will let you know the result.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36714886
Awesome good luck!  I think that last link might be exactly what you need.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

One of the most often confused topics in the area DNS is the idea of GLUE records. Specifically, what they are, when they are needed, when they are provided, and how they are created. First, WHAT IS GLUE? To understand GLUE, you must first under…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now