[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

how to set dns to allow the settings of TTL

Hi,
I have a small issue regarding dns, I would like a attributes to set TTL's of record.
Thanks.
0
lionel3030
Asked:
lionel3030
  • 10
  • 9
1 Solution
 
PapertripCommented:
Setting TTL's for records should be very straight forward.

Which DNS server are you running?
0
 
lionel3030Author Commented:
Hi Papertrip,
I used Bind
0
 
PapertripCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
lionel3030Author Commented:
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
 
PapertripCommented:
I'm not familiar with Chef -- do you use that to administer your DNS zones, or do you update them manually?
0
 
lionel3030Author Commented:
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
 
PapertripCommented:
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
 
lionel3030Author Commented:
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
 
lionel3030Author Commented:
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
 
PapertripCommented:
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
 
lionel3030Author Commented:
Yep it does but 1 thing i dont have anything to do to set attributes?
0
 
lionel3030Author Commented:
maybe this might work as well?
aws_creds = Chef::EncryptedDataBagItem.load("aws", "#{node[:mycompany_vars][:customer_name]}_keys")
0
 
PapertripCommented:
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
 
PapertripCommented:
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
 
lionel3030Author Commented:
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
 
PapertripCommented:
0
 
PapertripCommented:
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
 
lionel3030Author Commented:
thanks for all your help i will try to set theses lines into one if possible i will let you know the result.
0
 
PapertripCommented:
Awesome good luck!  I think that last link might be exactly what you need.
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now