@conf.commands.register
def dyndns_add(nameserver, name, rdata, type='A', ttl=10):
 zone = name[(name.find('.') + 1):]
 r = sr1(((IP(dst=nameserver) / UDP()) / DNS(opcode=5, qd=[DNSQR(qname=zone, qtype='SOA')], ns=[DNSRR(rrname=name, type='A', ttl=ttl, rdata=rdata)])), verbose=0, timeout=5)
 if (r and r.haslayer(DNS)):
  return r.getlayer(DNS).rcode
 else:
  return (-1)

@ conf . commands . register def dyndns_add ( nameserver , name , rdata , type = 'A' , ttl = 10 ) : zone = name [ ( name . find ( '.' ) + 1 ) : ] r = sr1 ( ( ( IP ( dst = nameserver ) / UDP ( ) ) / DNS ( opcode = 5 , qd = [ DNSQR ( qname = zone , qtype = 'SOA' ) ] , ns = [ DNSRR ( rrname = name , type = 'A' , ttl = ttl , rdata = rdata ) ] ) ) , verbose = 0 , timeout = 5 ) if ( r and r . haslayer ( DNS ) ) : return r . getlayer ( DNS ) . rcode else : return ( - 1 )
send a dns add message to a nameserver for "name" to have a new "rdata" dyndns_add -> result code example: dyndns_add rfc2136 .