Make TTL configurable
This commit is contained in:
parent
102b423896
commit
d962420de7
|
@ -1,6 +1,10 @@
|
|||
# vCenter integration plugin for NetBox
|
||||
# Dynamic DNS Connector for NetBox
|
||||
|
||||
This plugin shows live data from vCenter clusters in NetBox, making it easier for administrators to make sure that reality reflects what is documented in NetBox.
|
||||
This plugin lets you define DNS servers that support [RFC3007 Dynamic DNS Updates](https://tools.ietf.org/html/rfc3007). For each server you specify which domains and reverse DNS domains it is responsible for, and after that NetBox will automatically send DNS Updates to those servers whenever you change the DNS name of an IP Address in NetBox.
|
||||
|
||||
Updates are sent from the worker process in the background. You can see their progress either by configuring Django logging or by looking at the Background Tasks in the NetBox admin back-end.
|
||||
|
||||
For now all configuration is done in the NetBox admin back-end. A later version will provide a nicer user interface.
|
||||
|
||||
## Compatibility
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class ServerAdmin(admin.ModelAdmin):
|
|||
|
||||
@admin.register(Zone, site=admin_site)
|
||||
class ZoneAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'server')
|
||||
list_display = ('name', 'ttl', 'server')
|
||||
actions = [
|
||||
'update_all_records'
|
||||
]
|
||||
|
@ -83,7 +83,7 @@ class ZoneAdmin(admin.ModelAdmin):
|
|||
|
||||
@admin.register(ReverseZone, site=admin_site)
|
||||
class ReverseZoneAdmin(admin.ModelAdmin):
|
||||
list_display = ('prefix', 'name', 'server')
|
||||
list_display = ('prefix', 'name', 'ttl', 'server')
|
||||
list_filter = [IPFamilyFilter]
|
||||
actions = [
|
||||
'update_all_records'
|
||||
|
|
|
@ -135,7 +135,7 @@ def update_dns(old_address: IPAddress = None, new_address: IPAddress = None,
|
|||
update = zone.server.create_update(zone.name)
|
||||
update.add(
|
||||
new_dns_name + '.',
|
||||
300,
|
||||
zone.ttl,
|
||||
'a' if new_address.version == 4 else 'aaaa',
|
||||
str(new_address)
|
||||
)
|
||||
|
@ -160,7 +160,7 @@ def update_dns(old_address: IPAddress = None, new_address: IPAddress = None,
|
|||
update = zone.server.create_update(zone.name)
|
||||
update.add(
|
||||
record_name + '.',
|
||||
300,
|
||||
zone.ttl,
|
||||
'ptr',
|
||||
new_dns_name + '.'
|
||||
)
|
||||
|
|
25
netbox_ddns/migrations/0002_add_ttl.py
Normal file
25
netbox_ddns/migrations/0002_add_ttl.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 3.0.5 on 2020-04-14 23:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('netbox_ddns', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='reversezone',
|
||||
name='ttl',
|
||||
field=models.PositiveIntegerField(default=3600),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='zone',
|
||||
name='ttl',
|
||||
field=models.PositiveIntegerField(default=3600),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -89,6 +89,9 @@ class Zone(models.Model):
|
|||
validators=[HostnameValidator()],
|
||||
unique=True,
|
||||
)
|
||||
ttl = models.PositiveIntegerField(
|
||||
verbose_name=_('TTL'),
|
||||
)
|
||||
server = models.ForeignKey(
|
||||
to=Server,
|
||||
verbose_name=_('DDNS Server'),
|
||||
|
@ -122,6 +125,9 @@ class ReverseZone(models.Model):
|
|||
blank=True,
|
||||
help_text=_("RFC 2317 style reverse DNS, required when the prefix doesn't map to a reverse zone"),
|
||||
)
|
||||
ttl = models.PositiveIntegerField(
|
||||
verbose_name=_('TTL'),
|
||||
)
|
||||
server = models.ForeignKey(
|
||||
to=Server,
|
||||
verbose_name=_('DDNS Server'),
|
||||
|
|
Loading…
Reference in a new issue