Im trying to add a PTR record with dnspython to bind9 using this code:
def send_query(query, server):
update = dns.query
update.tcp(query, server)
def add(name, rdtype, rdata, ttl=300, zone):
server = dns.resolver.Resolver()
server.nameservers = '<dns server>'
keyring = dns.tsigkeyring.from_text({
'key-name': 'key'
})
record = dns.update.Update(zone=zone, keyring=keyring)
record.add(name, ttl, rdtype, rdata)
send_query(record, server.nameservers)
Im able to successfully add the record when passing:
name = last octet
rdtype = PTR
data = server-FQDN
zone = z.y.x.in-addr.arpa
but when querying the dns server via nslookup I get:
~ nslookup X.Y.Z.6
Server: NS server
Address: NS server#53
6.Z.Y.X.in-addr.arpa name = server-FQDN.Z.Y.X.in-addr.arpa.
The problem is the "Z.Y.X.in-addr.arpa." part added to the query.
In the zone file the record is in the right syntax
Is there a better way to add PTR record with dnspython?
The reason this didn't work was that I forgot to add the ending "." at the end of the hostname FDQN and therefore the domain was completed automatically.
Related
All emails with the domain #mycompany.com are sent successfully. But, if MantisBT wants to send an email to anyone else, for example #othercontractor.com, or #gmail.com, etc , the email is not sent.
In addition, a collateral damage of this problematic email is that it will get stuck in "MySqlDatabase/mantis_email_table" and all the emails after this problematic email in that table won't be sent. So, to fix it, I have to manually delete that entry in the table. It is not very convenient when I want to add contractor who has his own email domain in our bug tracker.
This the email configuration in: /path_to_mantis_bt/config/config_inc.php
// Email Configuration
$g_email_send_using_cronjob = ON;
$g_allow_signup = ON; //allows the users to sign up for a new account
$g_enable_email_notification = ON; //enables the email messages
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'edge.mycompany.com';
$g_smtp_connection_mode = '';
$g_smtp_port = 25;
$g_administrator_email = 'myname#mycompany.com';
$g_from_email = 'myname#mycompany.com';
$g_return_path_email = 'myname#mycompany.com';
$g_from_name = 'Mantis Bug Tracker';
I should mention that we are hosting MantisBT on our own server Microsoft Server 2012 R2 and WAMP(latest version).
The error: 2018-01-08 10:24 PST MAIL email_api.php:1379 email_send() ERROR: Message could not be sent - SMTP Error: The following recipients failed: xxx#gmail.com: 5.7.54 SMTP; Unable to relay recipient in non-accepted domain
It's working now, but I used sendmail instead of using the WAMP/SMTP.
To install SENDMAIL on WAMP, I followed these instructions
This the email configuration in: /path_to_mantis_bt/config/config_inc.php
$g_allow_signup = ON; //allows the users to sign up for a new account
$g_enable_email_notification = ON; //enables the email messages
$g_phpMailer_method = PHPMAILER_METHOD_SENDMAIL; //If not using sendmail, use: PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'edge.mycompany.com';
$g_smtp_connection_mode = 'tls';
$g_smtp_port = 587;
$g_smtp_username = 'xxx'; // my username for email myname#mycompany.com
$g_smtp_password = 'xxx'; // my password for email myname#mycompany.com
$g_administrator_email = 'myname#mycompany.com';
$g_webmaster_email = 'myname#mycompany.com';
$g_from_email = 'myname#mycompany.com';
$g_return_path_email = 'myname#mycompany.com';
$g_from_name = 'Mantis Bug Tracker';
// Log configuration
$g_log_level = LOG_EMAIL | LOG_EMAIL_RECIPIENT | LOG_FILTERING | LOG_AJAX;
$g_log_destination = 'file:/wamp64/logs/mantis.log';
?>
IF you follow the link above, you will know how to update php.ini and sendmail.ini . Update these 2 files with the information in config_inc.php.
I had the same issue. In my case, we were sending out emails from an application and there was a user bcced (hardcoded in the code) which was not in the domain and hence it failed
I had same issue once I changed to #newdomain.com.
In my case I found suggestion on the web to clear cache of my browser. I did and all start working.
Basically, you need to reload all config files from scratch with new globals...
At least it worked for me.
Cheers.
I previously had a website working on AWS. It was created & registered with AWS. It was setup in the hosted zone and point to an EC2 instance. Everything was working fine.
I got "smart" and created a load balancer, which pointed to the EC2 instance, and then I deleted the previous hosted zone record (and associated recordset) and re-added the hosted zone record which would point to the load balancer.
After much googling I determined I needed to add an "A" record, make it an alias and point it to the load balancer. All good so far.
Then I went to access the website in browser and Im getting ERR_NAME_NOT_RESOLVED. I waited hours for DNS servers to update and still no luck. Flushed DNS cache and no luck.
Ive changed multiple other things - tried www in front of name in recordset, tried a ptr record which pointed to load balancer DNS name, and even tried to sync the dns server names between the domain record and the hosted zone record. Still no luck. Same error.
Ive performed "nslookup debug" and honestly dont know what Im looking at.
C:\Users\sam>nslookup -debug abc.com
Got answer:
HEADER:
opcode = QUERY, id = 1, rcode = NOERROR
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 0, additional = 0
QUESTIONS:
1.1.168.192.in-addr.arpa, type = PTR, class = IN
ANSWERS:
-> 1.1.168.192.in-addr.arpa
name = xyz
ttl = 0 (0 secs)
Server: xyz
Address: 192.168.1.1
Got answer:
HEADER:
opcode = QUERY, id = 2, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = A, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 3, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = AAAA, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 4, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = A, class = IN
------------
Got answer:
HEADER:
opcode = QUERY, id = 5, rcode = SERVFAIL
header flags: response, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
abc.com, type = AAAA, class = IN
*** xyzcan't find abc.com: Server failed
Im sure its something dumb. But Ive spent too much time on this and cant think anymore.
What did I do wrong?
Thanks for your help.
even tried to sync the dns server names between the domain record and the hosted zone record.
If that was necessary, then it sounds like at some point you deleted and recreated the hosted zone... which does not work the way you may have anticipated.
The simplest way out of that, is this:
Leaving the existing zone exactly as it is, create a new hosted zone with the same domain. (Yes, this works).
Note the four name servers assigned for the new hosted zone.
Go to the domain record (the registrar component of Route 53, not the hosted zone component) and change the 4 name servers to match those assigned to your new hosted zone.
In the new hosted zone, create a new A record, hostname box empty, Alias = Yes, and select the ELB name.
Once it's working, delete the old hosted zone.
I want to get all the datastores from a specific cluster. I will be using this for my vapp deployment.
i tried the following snippet:
clusters = server.get_clusters()
for c_mor, c_name in clusters.items():
for ds_mor, name in server.get_datastores(from_mor=c_mor).items():
props = VIProperty(server, ds_mor)
print props.name
However, this does not give me the list. What am I doing wrong?
It's to late for answer this question. this my code.
from pysphere import VIServer, VIProperty
server = VIServer()
server.connect(server, username, password)
for ds_mor, name in server.get_hosts().items():
props = VIProperty(server, ds_mor)
for item in props.datastore :
print item.info.name
server.disconnect()
Old question but if anyone outside is looking for a solution (this is the first result in google), this will directly gather information from datastores:
from pysphere import VIServer, VIProperty
import ssl
default_context = ssl._create_default_https_context
server = VIServer()
#user = the-user-to-connect-to-vsphere
#password = the-password-from-the-user
#host = the-vsphere-hostname-or-ip
try:
ssl._create_default_https_context = ssl._create_unverified_context
server.connect(host, user, password)
for ds_mor, name in server.get_datastores().items():
props = VIProperty(server, ds_mor)
print "Datastore name: ", name
server.disconnect()
finally:
ssl._create_default_https_context = default_context
This will connect to self-signed VSphere, as is usual de case in an intranet.
I am trying to use GeoIP, but I have a problem when I use REMOTE_ADDR. The IP shown is that of my server and not the client.
from django.contrib.gis.geoip import GeoIP
Example context:
g = GeoIP()
ip = self.request.META.get('REMOTE_ADDR')
context['my_ip'] = ip # this display ip client
context['pais_anuncio'] = g.country_code('ip') # this display ip my server.
What am I doing wrong, Thank you.
My guess is, since you are passing the string 'ip', it is defaulting to your server's IP. Try passing in the variable ip, like this:
context['pais_anuncio'] = g.country_code(ip)
I have a VBscript which works abolultuly fine on my workstation. It queries SCCM to find out what domain a computer is in. When I run it as part of the task sequence, it fails. Note that this is almost the last step in the task sequence, under Windows 7, not Windows PE.
Option Explicit
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim computerName, userName, userPassword, server
Dim swbemLocator, swbemServices, providerLoc
Dim location, connection
Dim query, found, resource, resources
'--- Settings ---
userName = "domain\username"
userPassword = "password"
server = "domain.com"
'--- Get computer name ---
computerName = CreateObject("WScript.Network").ComputerName
WScript.Echo"Computer name: " & computerName
'--- Connect ----
Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")
swbemLocator.Security_.AuthenticationLevel = 6
Set swbemServices = swbemLocator.ConnectServer(server, "root\sms",userName,userPassword)
Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")
For Each location In providerLoc
If location.ProviderForLocalSite = True Then
WScript.Echo "SiteCode: " & location.SiteCode
Set connection = swbemLocator.ConnectServer(server, "root\sms\site_" + location.SiteCode)
Else
WScript.Echo "Not provider for local site."
End If
Next
'--- Query & output ---
query = "SELECT * FROM SMS_FullCollectionMembership WHERE name = '" & computerName & "'"
Set resources = connection.ExecQuery(query, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
found = False
For Each resource In resources
WScript.Echo "Domain: " & resource.Domain & " (" & resource.CollectionID & ")"
found = True
Exit For
Next
If Not found Then WScript.Echo "Computer not found!"
If I open a command prompt ruing the task sequence (using F8 under Windows 7, not Windows PE) and run the script, I get:
SWbemLocator: Access is denied
on the line:
Set connection = swbemLocator.ConnectServer(server, "root\sms\site_" + location.SiteCode)
Any thoughts? Alternatively, any other suggestions on how to find out what domain a computer was in last time it was built?
Your Task Sequence runs in context of the the local system account, and per default this account has no rights in SCCM.
If you define "yourdomain\domain computers" in the SCCM admin console, Security Rights, Users, and give them read and read resource rights on Collection, you should be able to connect to your SCCM server.
Please notice, you have to do this on all site servers you want to connect to, these definitons are not replicated between sites.
I realise this is a very old post but I just had this problem myself.
You already have the username and password in the script and it is used here
Set swbemServices = swbemLocator.ConnectServer(server, "root\sms",userName,userPassword)
However just a bit further down you are making a connection to the site without the username and password.
Set connection = swbemLocator.ConnectServer(server, "root\sms\site_" + location.SiteCode)
Try this:
Set connection = swbemLocator.ConnectServer(server, "root\sms\site_" + location.SiteCode, userName, userPassword)
Hope this helps someone!