【问题标题】:Boto Route53 or Area53 - How to add multiple ipaddress to a subdomainBoto Route53 或 Area53 - 如何将多个 ipaddress 添加到子域
【发布时间】:2012-07-02 09:59:31
【问题描述】:

我正在尝试在路由 54 的子域下添加多个 IP 地址。在 UI 上就足够了,使用 area54 或在 boto 中添加一个 IP 地址很容易。

e.g. master.hui.com
10.130.149.247
10.130.149.248

使用区域54

ipaddress = '10.130.149.247'
entry =  'master.hui.com'
zone = route53.get_zone('hui.com')
add_dns = zone.add_record('A',entry, [ipaddress], ttl='60') 

在博托:

conn = Route53Connection(aws_access_key_id, aws_secret_access_key)
changes = ResourceRecordSets(conn, zone_id)

change = changes.add_change("CREATE",sub_domain, "A", 60)
change.add_value(ip_address)

那么...如何使用 area53 或 boto 在子域下添加两个或多个 IP 地址?

谢谢

【问题讨论】:

    标签: python dns boto amazon-route53


    【解决方案1】:

    您需要使用 WRR。从 boto CLI:

    route53 add_record Z1J8BS4AFAKE12 foo.example.com. A 1.2.3.4 60 first 1
    route53 add_record Z1J8BS4AFAKE12 foo.example.com. A 5.6.7.8 60 second 2
    

    或来自 API:

    change.add_change("CREATE", 'foo', 'A', ttl=60, weight=1, identifier='first')
    change.add_change("CREATE", 'foo', 'A', ttl=60, weight=2, identifier='second')
    

    http://docs.amazonwebservices.com/Route53/latest/DeveloperGuide/WeightedResourceRecordSets.html

    最后,您所说的“子域”是“资源记录”。当您将此问题发送到 boto-users 邮件列表时,“子域”意味着一个让我感到困惑的区域。

    【讨论】:

    • 谢谢...取得进展。我能够添加我称之为子域的资源记录。当我运行代码时,有两条单独的记录,它们的区别仅在于权重和集合 id。从 aws UI,我可以输入 ip 地址作为逗号分隔列表,但都在一个记录上。如果有的话,这有什么不同。此外,对于权重,我假设它们将是 50/50 的随机数?
    • 没关系...用重量得到它。感谢您的解决方案:)
    【解决方案2】:

    最初的问题和接受的答案都很好,但也许 boto 的界面已经改变,所以我在做同样的事情时遇到了一些问题或细节。

    如果您想使用 boto 添加一个或多个加权 DNS,代码为(注意我使用的是 CNAME 记录而不是 A 记录):

    conn = Route53Connection(aws_access_key_id, aws_secret_access_key)
    rrs = ResourceRecordSets(conn, zone_id, comment='for posterity')
    
    change = rrs.add_change('CREATE', fqdn, 'CNAME', ttl=60, identifier='unique', weight=1)
    change.add_value(where_the_DNS_should_point_to)
    
    try:
       status = rrs.commit()
    except DNSServerError:
       # something went wrong, handle it as you please
       pass
    
    # here you should wait until status is no longer PENDING
    

    为了完整起见,这里是删除同一条记录的最简单方法:

    conn = Route53Connection(aws_access_key_id, aws_secret_access_key)
    zone = conn.get_zone(your_zone_name)
    
    rr = zone.find_records(fqdn, 'CNAME', identifier=('unique', '1'))
    # check here that rr is not None
    status = zone.delete_record(rr, comment='for posterity')
    # here you should wait until status is no longer PENDING
    

    【讨论】:

    • 我刚刚在 2.38.0 上使用了相同的方法,并且成功了。
    猜你喜欢
    • 1970-01-01
    • 2018-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 1970-01-01
    • 2018-05-24
    • 1970-01-01
    相关资源
    最近更新 更多