How to Add MX Records (Convention)

106 views
Skip to first unread message

Joshua Piper

unread,
Oct 23, 2020, 10:35:06 PM10/23/20
to dnspython-users
Hi,

I have the following;

#Insert query into the DNS BIND09 Server
zone = dns.update.Update(parentZone, keyring=key) 
zone.add(sub_domain, 86400, dns.rdatatype.MX, ip)

Where I define sub_domain, ip, parentZone and key elsewhere.
I get the following error.

  File "/usr/local/lib/python3.7/site-packages/dns/rdata.py", line 478, in from_text
    relativize_to)
  File "/usr/local/lib/python3.7/site-packages/dns/rdtypes/mxbase.py", line 45, in from_text
    preference = tok.get_uint16()
  File "/usr/local/lib/python3.7/site-packages/dns/tokenizer.py", line 507, in get_uint16
    value = self.get_int(base=base)
  File "/usr/local/lib/python3.7/site-packages/dns/tokenizer.py", line 480, in get_int
    raise dns.exception.SyntaxError('expecting an integer')
dns.exception.SyntaxError: expecting an integer

I am confused where I am going here, as it works for CNAME and A.

Kind regards,

J.

Joshua Piper

unread,
Oct 23, 2020, 11:21:48 PM10/23/20
to dnspython-users
I have tried other online documentation. All documentation related to MX is for creating the zone file from scratch.

My other method of trying to add a MX was with the 2 parameters rdataset and name. Thus,

 #Declare parametres gathered from webpage.
try:

#Insert query into the DNS BIND09 Server
zone = dns.update.Update('unix', keyring=key)
ds = dns.rdataset.Rdataset(dns.rdataclass.ANY, dns.rdatatype.MX, 16, 86400)
zone.add('@', ds)
response = dns.query.tcp(zone, '127.0.0.1')
except Exception as e:
print(e)

However, the rdataset covered arg seems to be confusing as the documentation doesn't led to it?
Maye if I was pointed in the right direction for that. As I believe the 3 args method wont create an MX.




--
You received this message because you are subscribed to a topic in the Google Groups "dnspython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dnspython-users/7VjPd3UdexU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dnspython-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dnspython-users/a2989b28-445a-4596-ab52-fae8581263d7n%40googlegroups.com.

Bob Halley

unread,
Oct 24, 2020, 1:28:02 PM10/24/20
to dnspython-users
The value for an MX record in the update add() API is the text form of an MX record.  That's an unsigned 16-bit integer preference followed by a name, e.g. "10 mail1.example.com".  The error message says that the MX parser is trying to parse the integer part, and what its getting is not an integer.  You call your parameter "ip", and if it has an IP address that definitely won't work.

Goo Gle

unread,
Feb 23, 2021, 3:31:54 PM2/23/21
to dnspython-users, Goo Gle
I have a two part question and a one part “deep sigh."

“Message Digest for DNS Zones”, aka RFC 8976, was published this month by the IETF and I’ve already heard a request to have it deployed. DNS Python 2.1.0 does not have ZONEMD (for type 63). I assume there’ll be an update needed, is there any idea on what version number will have ZONEMD and approximately “when”?

While researching this and trying to future-proof, I found that a Debian Buster (10.6) and a Ubuntu 18.04 machine “think” that DNS Python 1.16 or DNS Python 1.15 is the latest version - according to the stock package dispensaries. I see that a future Debian and a future Ubuntu have DNS Python 2 mentioned, but is there no way to speed up the inclusion of DNS Python 2 in those open source operating systems? Apple has DNS Python 2 in Big Sur and I think Catalina.

I want to avoid downloading and manually installing DNS Python because, in general, I’m already completely confused over python’s way of managing packages. I realize I could do that, but, I’m lazy.

Anand Buddhdev

unread,
Feb 24, 2021, 4:15:48 AM2/24/21
to Goo Gle, dnspython-users
On 23/02/2021 21:31, Goo Gle wrote:

Hello Goo Gle,

[snip]

> While researching this and trying to future-proof, I found that a
> Debian Buster (10.6) and a Ubuntu 18.04 machine “think” that DNS Python
> 1.16 or DNS Python 1.15 is the latest version - according to the stock
> package dispensaries. I see that a future Debian and a future Ubuntu
> have DNS Python 2 mentioned, but is there no way to speed up the
> inclusion of DNS Python 2 in those open source operating systems? Apple
> has DNS Python 2 in Big Sur and I think Catalina.

Your question doesn't really belong here. It's better to ask this
question in some Debian or Ubuntu forum or list.

I also don't know what you mean by Apple including dnspython in Big Sur.
I am using Big Sur, and there's no dnspython module included with the
system python.

> I want to avoid downloading and manually installing DNS Python
> because, in general, I’m already completely confused over python’s way
> of managing packages. I realize I could do that, but, I’m lazy.

You don't have to give up your laziness. Just run:

pip install dnspython

in your virtualenv. It's just one command :)

Regards,
Anand

Bob Halley

unread,
Feb 25, 2021, 12:07:16 PM2/25/21
to dnspython-users
ZONEMD support is coming to dnspython soon, and will be in the 2.2 release, though we don't have a release schedule for it yet.

I agree with the advice about just installing the current dnspython package with pip in a virtualenv.

Goo Gle

unread,
Feb 25, 2021, 7:23:36 PM2/25/21
to Anand Buddhdev, Goo Gle, dnspython-users
On Feb 24, 2021, at 04:15, Anand Buddhdev <ana...@ripe.net> wrote:

> Your question doesn't really belong here. It's better to ask this
> question in some Debian or Ubuntu forum or list.

I was wondering if it was a “push” or “pull” issue, whether dnspython had to be opened to the OS’ers or whether they just weren’t pulling it.

> I also don't know what you mean by Apple including dnspython in Big Sur.
> I am using Big Sur, and there's no dnspython module included with the
> system python.

I don’t recall how I did it, but I just used a stock package manager (homebrew perhaps, probably). I know I didn’t go seeking v2 as when I put my existing stuff on it, it broke related to a change from v1 to v2. (Not to complain, just why I recall this.)

> You don't have to give up your laziness. Just run:
>
> pip install dnspython
>
> in your virtualenv. It's just one command :)

Not to dwell, but I’d been using the apt upgrade “thing” and it only has v1 dnspython on the Debian/Ubuntu. (I’m no sysadmin, I didn’t even realize the two machines had different OS’s until I was digging into this.)
Reply all
Reply to author
Forward
0 new messages