ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to write a perl script that can reverse lookup 250K+ IP addresses.
I tried to use Gethostbyname. That seemed to work -- it flew through the entries -- thousands/min. But, as soon as it got stuck on a IP, it would wait an insanely long time before moving onto the next entry.
So, I switched to Net::DNS. (<--not sure how to dump the smiley here...heh... that's a D) This worked -- I set the timeout to 5 seconds. But, it was way slower, by like a factor of 10+. I guess this is because it's opening a seperate socket for each connection? So, it took 12+ hours to lookup about 220K IPs.
Anyone know a better way to do this? I thought I might just modify the Gethostbyname code to allow a timeout (or, probably just change it). But, not sure how Perl is implementing that, and what else it would affect.
DNS lookups are short UDP packets - the fastest possible way to do those lookups would be to run tcpdump to capture the replies, then write a short perl script to pump every DNS query packet you want out all at once (Net:NS helps you construct that).
to make it even faster, you could spread the load and use multiple different servers (eg: send some requests to 8.8.8.8 and others to 8.8.4.4 etc).
The entire run should take just 10 or 20 seconds this way (depends a bit on your outgoing traffic bandwidth)
So, I switched to Net::DNS. (<--not sure how to dump the smiley here...heh... that's a D)
Code:
[noparse]Net::DNS[/noparse]
Works in quotes too. but usage is a bit tedious after multiple replies.
Or as Jeremy said select "Disable smilies in text" in Additional Options of Reply to Thread Window.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.