nslookup using server alternative in python
I'm looking for a python replacement for nslookup.
Other sources have pointed me towards socket.getaddrinfo(). However, this does not seem to allow me to specify a server through which to resolve a hostname, which nslookup supports and I require.
C:UsersAdministrator>nslookup 10.0.11.6 coolserver
Server: coolserv.coolserver.com
Address: 10.0.1.1
Name: the-host-name-i-want.blah.com
Address: 10.0.11.6
It is a requirement that I be able to do the lookup through "coolserver". Is this something socket or any other python library is capable of?
I'm aware that I can just call nslookup directly through subprocess.
EDIT:
As explained above, this is not a duplicate of python module for nslookup
To my knowledge, socket.getaddrinfo() does not allow you to route the request through a server. I need to know "what does this server think my hostname is". Not "what is my local hostname".
python windows nslookup
add a comment |
I'm looking for a python replacement for nslookup.
Other sources have pointed me towards socket.getaddrinfo(). However, this does not seem to allow me to specify a server through which to resolve a hostname, which nslookup supports and I require.
C:UsersAdministrator>nslookup 10.0.11.6 coolserver
Server: coolserv.coolserver.com
Address: 10.0.1.1
Name: the-host-name-i-want.blah.com
Address: 10.0.11.6
It is a requirement that I be able to do the lookup through "coolserver". Is this something socket or any other python library is capable of?
I'm aware that I can just call nslookup directly through subprocess.
EDIT:
As explained above, this is not a duplicate of python module for nslookup
To my knowledge, socket.getaddrinfo() does not allow you to route the request through a server. I need to know "what does this server think my hostname is". Not "what is my local hostname".
python windows nslookup
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
1
Not a duplicate. As I said in the OP,socket.getaddrinfodoes not allow you to specify a server, which is the functionality I need.
– Daniel Paczuski Bak
Nov 20 '18 at 20:27
1
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45
add a comment |
I'm looking for a python replacement for nslookup.
Other sources have pointed me towards socket.getaddrinfo(). However, this does not seem to allow me to specify a server through which to resolve a hostname, which nslookup supports and I require.
C:UsersAdministrator>nslookup 10.0.11.6 coolserver
Server: coolserv.coolserver.com
Address: 10.0.1.1
Name: the-host-name-i-want.blah.com
Address: 10.0.11.6
It is a requirement that I be able to do the lookup through "coolserver". Is this something socket or any other python library is capable of?
I'm aware that I can just call nslookup directly through subprocess.
EDIT:
As explained above, this is not a duplicate of python module for nslookup
To my knowledge, socket.getaddrinfo() does not allow you to route the request through a server. I need to know "what does this server think my hostname is". Not "what is my local hostname".
python windows nslookup
I'm looking for a python replacement for nslookup.
Other sources have pointed me towards socket.getaddrinfo(). However, this does not seem to allow me to specify a server through which to resolve a hostname, which nslookup supports and I require.
C:UsersAdministrator>nslookup 10.0.11.6 coolserver
Server: coolserv.coolserver.com
Address: 10.0.1.1
Name: the-host-name-i-want.blah.com
Address: 10.0.11.6
It is a requirement that I be able to do the lookup through "coolserver". Is this something socket or any other python library is capable of?
I'm aware that I can just call nslookup directly through subprocess.
EDIT:
As explained above, this is not a duplicate of python module for nslookup
To my knowledge, socket.getaddrinfo() does not allow you to route the request through a server. I need to know "what does this server think my hostname is". Not "what is my local hostname".
python windows nslookup
python windows nslookup
edited Nov 20 '18 at 20:31
Daniel Paczuski Bak
asked Nov 20 '18 at 19:58
Daniel Paczuski BakDaniel Paczuski Bak
8461930
8461930
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
1
Not a duplicate. As I said in the OP,socket.getaddrinfodoes not allow you to specify a server, which is the functionality I need.
– Daniel Paczuski Bak
Nov 20 '18 at 20:27
1
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45
add a comment |
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
1
Not a duplicate. As I said in the OP,socket.getaddrinfodoes not allow you to specify a server, which is the functionality I need.
– Daniel Paczuski Bak
Nov 20 '18 at 20:27
1
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
1
1
Not a duplicate. As I said in the OP,
socket.getaddrinfo does not allow you to specify a server, which is the functionality I need.– Daniel Paczuski Bak
Nov 20 '18 at 20:27
Not a duplicate. As I said in the OP,
socket.getaddrinfo does not allow you to specify a server, which is the functionality I need.– Daniel Paczuski Bak
Nov 20 '18 at 20:27
1
1
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45
add a comment |
1 Answer
1
active
oldest
votes
You need to create a resolver object and set the resolvers to the DNS servers you want to use:
from dns import *
resolver = resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
a = resolver.query('duckduckgo.com','A')
a.rrset.items[0].address #'54.241.2.241'
To do a reverse lookup do this:
r =reversename.from_address('50.18.200.106')
ra = resolver.query(r,'PTR')
ra.rrset.items[0].to_text() # 'ec2-50-18-200-106.us-west-1.compute.amazonaws.com.'
Note ec2-50-18-200-106.us-west-1.compute.amazonaws.com is a duckduckgo.com web server.
You may need to install dnspython.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400642%2fnslookup-using-server-alternative-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to create a resolver object and set the resolvers to the DNS servers you want to use:
from dns import *
resolver = resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
a = resolver.query('duckduckgo.com','A')
a.rrset.items[0].address #'54.241.2.241'
To do a reverse lookup do this:
r =reversename.from_address('50.18.200.106')
ra = resolver.query(r,'PTR')
ra.rrset.items[0].to_text() # 'ec2-50-18-200-106.us-west-1.compute.amazonaws.com.'
Note ec2-50-18-200-106.us-west-1.compute.amazonaws.com is a duckduckgo.com web server.
You may need to install dnspython.
add a comment |
You need to create a resolver object and set the resolvers to the DNS servers you want to use:
from dns import *
resolver = resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
a = resolver.query('duckduckgo.com','A')
a.rrset.items[0].address #'54.241.2.241'
To do a reverse lookup do this:
r =reversename.from_address('50.18.200.106')
ra = resolver.query(r,'PTR')
ra.rrset.items[0].to_text() # 'ec2-50-18-200-106.us-west-1.compute.amazonaws.com.'
Note ec2-50-18-200-106.us-west-1.compute.amazonaws.com is a duckduckgo.com web server.
You may need to install dnspython.
add a comment |
You need to create a resolver object and set the resolvers to the DNS servers you want to use:
from dns import *
resolver = resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
a = resolver.query('duckduckgo.com','A')
a.rrset.items[0].address #'54.241.2.241'
To do a reverse lookup do this:
r =reversename.from_address('50.18.200.106')
ra = resolver.query(r,'PTR')
ra.rrset.items[0].to_text() # 'ec2-50-18-200-106.us-west-1.compute.amazonaws.com.'
Note ec2-50-18-200-106.us-west-1.compute.amazonaws.com is a duckduckgo.com web server.
You may need to install dnspython.
You need to create a resolver object and set the resolvers to the DNS servers you want to use:
from dns import *
resolver = resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
a = resolver.query('duckduckgo.com','A')
a.rrset.items[0].address #'54.241.2.241'
To do a reverse lookup do this:
r =reversename.from_address('50.18.200.106')
ra = resolver.query(r,'PTR')
ra.rrset.items[0].to_text() # 'ec2-50-18-200-106.us-west-1.compute.amazonaws.com.'
Note ec2-50-18-200-106.us-west-1.compute.amazonaws.com is a duckduckgo.com web server.
You may need to install dnspython.
edited Nov 20 '18 at 21:12
answered Nov 20 '18 at 20:49
Red CricketRed Cricket
4,36993383
4,36993383
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400642%2fnslookup-using-server-alternative-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of python module for nslookup
– Aurora Wang
Nov 20 '18 at 20:21
1
Not a duplicate. As I said in the OP,
socket.getaddrinfodoes not allow you to specify a server, which is the functionality I need.– Daniel Paczuski Bak
Nov 20 '18 at 20:27
1
Are you looking for dnspython ?
– Maurice Meyer
Nov 20 '18 at 20:45