The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 04:38:56 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Utilizing Multiple IPs on a VPS  (Read 638 times)
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 509


View Profile
« on: January 06, 2010, 07:43:31 AM »

I'm a unix moran and although I've toyed with VPSs for a year or two, I've just
run a script or two, never really got into it deeply.

The VPS that I have now has one IP and no domains or websites.  I just use
ssh and ftp to manage the running of my perl code there.

I would like to run a second copy of one script in particular that access a certain host,
but I think it would need to be on a different IP.  I can get additional IPs easy enough,
but how do I tell my perl scripts which IP to run on?

/confused

Bompa
Logged

"Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted." -- Albert Einstein
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #1 on: January 06, 2010, 02:38:01 PM »

Not an easy think to do bomps Smiley
It took me like a zillion years to search thru docs.

I presume u want to change ur IP because ur first one got banned ?
If that not reason, then no need to change.

For lwp http://search.cpan.org/~gaas/libwww-perl-5.834/lib/LWP/UserAgent.pm
set it with option local_address

for ftp I have no idea Smiley
In some cases u can not directly change IP, unless u poke arround in source and patch.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #2 on: January 06, 2010, 03:34:47 PM »

Weird zone - IPs and VPSs.

I'm guessing if your provider adds the IP to your VPS then it will show up as an available address for inbound discussions, like for an Apache server. You could make up some crap about needing IPs for SSL certs or something.

Once the physical plumbing is established, then you'd need to bind your script to the IP, because every outbound request will use the default gateway (root address) when sending packets out. There are threads here and Syndk8 for PHP binding, but I've not seen something for PERL - although I'll betcha that Dirk would know how to do it.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #3 on: January 06, 2010, 03:55:24 PM »

It's a "simple" one-liner:

@LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => $local_ip);

That's it.
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 509


View Profile
« Reply #4 on: February 20, 2010, 12:36:18 AM »

Not an easy think to do bomps Smiley
It took me like a zillion years to search thru docs.

I presume u want to change ur IP because ur first one got banned ?
If that not reason, then no need to change.

For lwp http://search.cpan.org/~gaas/libwww-perl-5.834/lib/LWP/UserAgent.pm
set it with option local_address

Not banned yet.  An example would be running a Google search.  If I query them too
fast, eventually, Google would ban or throttle my IP.  So, having two IPs I can go
more slowly yet not loose my production level.

Anyways, you and Dirk gave me the answer:

$ua = LWP::UserAgent->new(LocalAddr => $local_ip);
OR
@LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => $local_ip);


Thanks to both of you.


Funny thing, I thought no one replied to this thread, so I just shrugged it off.
From time to time, I remember that I asked the question here, but it was not
an emergency situation.

Today I was thinking about this again and decided to google it.

http://www.google.com/search?hl=en&safe=off&q=how+to+use+multiple+IP+on+vps&start=10&sa=N

That's how I found out that this thread got replies and answers.

LOL

Bomps
« Last Edit: February 20, 2010, 12:55:54 AM by Bompa » Logged

"Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted." -- Albert Einstein
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!