[Home]LWP Use Multiple IP Addresses On A Multihomed Machine

Contents | (Visit Preferences to set your user name.) | Related To LWP Use Multiple IP Addresses On A Multihomed Machine | RecentChanges | Preferences | Index | Login | Logout

Featured: Featured Stories | Picture Gallery

Stages Of Behavior Change | McGrady
Google
Chat11.com Web Bible11.com MyBibleCenter.com
Cover of ISBN 0834003465 Cover of ISBN 0785201688
Cover of ISBN 081297476X The Bush Survival Guide - 250 Ways to Make It Through The NExt Four Years Without Misunderestimating the Dangers Ahead, and Other Subliminable Stategeries
Links:

Let LWP Use Multiple IP Addresses On A Machine

Subjects > Computers > Internet

Stepping through finding a solution


By Garnet

Remember how I was wondering how to send pings, and web requests, and other net requests, from something other than the first IP address bound to a multihomed machine?

After years of wondering how to do this, I decided to spend a few hours single stepping through the perl libraries, since the main place I want to do this from is from the [spiders] that I write. I got rid of some of my internet servers recently, so I now have less places to run spiders from. Sometimes I need to run a lot of copies of a given spider so I can get thousands of requests finished faster.

After a couple of hours, I finally discovered a place in the perl runtime libraries where I could specify a localaddress which could be one of the addresses of the machine. So my click11 server, that has a dozen IP addresses bound to it, I can send a web get request from a perl program from any of the IP addresses on the machine.

Then I was trying to figure out how to hack this into the libraries, since at first I just hard coded an alternate address into the perl library. I finally figured out what a somewhat odd thing was that I’d been stepping over. Then finally how to set the value it was returning. Now that I know what to do, I did a search for that variable, EXTRA_SOCK_OPTS, and found what I had been looking for.

 binding LWP to a specific interface 
 After search and googleing for an answer a nice fellow in #perl (undernet)
 came up with the following:
 @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( LocalAddr  => q(ip.addr) ); 
 Posted by sps at 10:54 AM 

Too bad I never figured out that way to ask the question on google, or maybe I could have found the solution a lot sooner…..

So this doesn’t help me for stuff run from the command line like ping, or for the .NET framework spiders I write in C#, but maybe I can find something for them too. Turns out it looks like at the socket level, the magic thing is to bind to a specific address before the connect statement actually does the web request. It appears the default is to specify ANY_ADDR and let the winsock layer choose something.

Benefits of Perl and Open Source To Finding Solutions

Going through and finding this kind of thing in Perl was a lot easier than with any other language I use. Once I had a suspicion of where I needed to specify a localaddress, it was very easy to hack the statement into the perl run time libraries. I didn’t need to worry about recompiling or anything like that. I don’t know how I’ll be able to replicate this process with .NET, since it doesn’t like to expose it’s assemblies to such easy hacking, since everything there is compiled.

Go and see the shuttle land

I think I just heard (August 7 2005) something about Mountain View NASA opening their doors to people who want to watch the shuttle landing tonight….


Check out [Facts About Trees]


Contents | (Visit Preferences to set your user name.) | Related To LWP Use Multiple IP Addresses On A Multihomed Machine | RecentChanges | Preferences | Index | Login | Logout
Edit this www.chat11.com page | View other versions
Last edited March 21, 2008 7:30 pm (diff)
Search:
Sign up for PayPal and start accepting credit card payments
instantly.
Bobsgear - Get A Free Enterrpise Wiki Space!
Review: The Bobsgear Project was started to develop a variety of Confluence plugins. This installation of the Confluence Enterprise wiki includes flexible attachments, many Confluence plugins, personal blogs, interesting articles, and more. Bobsgear already has spaces related to politics, art and photography wiki, technical issues wiki, ediscovery wiki, health, Christian theology and Sabbath School wiki, the bible, book reviews, and quotations. Bobsgear allows free signup, and invites anyone to create a free hosted Confluence wiki space.


NEW USERS CLICK HERE! for a quick introduction to Wiki.

 

 Interested in What To Do With Leftovers?
223 total hits since 10/2007
Recently accessed pages: Consumer Protection Fertility Fryes Electronics Store General Gloria Swanson Greek Spinach Pie Hurricanes PPC-6600 Popular Alabama Topics Rush Limbaugh Show Search Engine Visimo Seventh-Day Adventist Elder Guide Break Out Session For Chapter 6 Wedding Quotation - Gift From The Sea

Elapsed:1