Sep-19-2020, 01:52 PM
Hi everyone, I'm new to Python and new to this site so I apologize if this question has been asked and answered before.
I'm trying to do a DNS lookup to get the IP of a device on our corporate network - not a device in the public domain.
Our devices have general names like Site#-deviceType-number. When I ssh to them, I'm assuming there is a DNS lookup done, and I'm guided to the correct IP address in the background.
I've written a program that logs into our cisco and ciena equipment and runs some commands - but it only works if I supply the IP address - not the device name. I'd like to write some code that does a quick lookup and then proceeds with the rest of my program.
So far I've tried working with resolver.Resolver() and Nslookup but I'm just not having any luck.
The closest thing I have to a success is this (success meaning it didn't give me any errors, but it just returns empty lists):
I'm trying to do a DNS lookup to get the IP of a device on our corporate network - not a device in the public domain.
Our devices have general names like Site#-deviceType-number. When I ssh to them, I'm assuming there is a DNS lookup done, and I'm guided to the correct IP address in the background.
I've written a program that logs into our cisco and ciena equipment and runs some commands - but it only works if I supply the IP address - not the device name. I'd like to write some code that does a quick lookup and then proceeds with the rest of my program.
So far I've tried working with resolver.Resolver() and Nslookup but I'm just not having any luck.
The closest thing I have to a success is this (success meaning it didn't give me any errors, but it just returns empty lists):
from nslookup import Nslookup device_name = "my_device_name" dns_query = Nslookup(dns_servers=["dns.ip.add.rss"]) # the actual ip address obviously ip_address = dns_query.dns_lookup(device_name) print(ip_address.response_full, ip_address.answer)[/font]