[issue3972] Add Option to Bind to a Local IP Address in httplib.py
report at bugs.python.org
Mon Dec 28 23:11:05 CET 2009
Antoine Pitrou <pitrou at free.fr> added the comment:
> For my own case, I have a machine with 50 IP addresses set and I need to
> run a script to grab data that will randomly select one of those IP
> addresses to use for its outgoing connection. That's something which
> needs to be selected at the socket level, as best I understand the issue,
> not on the routing end.
Why do you need to select manually between those 50 IP addresses?
Load-balancing? Fooling the remote server so that you don't get
blacklisted for opening too many connections?
The problem I see with adding this to httplib is that it's not
HTTP-specific. Other modules (smtplib etc.) might want to benefit,
depending on the use case.
By the way, what I mean by routing is your OS' internal routing table
for outbound packets. For example under Linux:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
X.Y.223.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
X.Y.222.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 X.Y.222.254 0.0.0.0 UG 100 0 0 eth0
The interface for each outbound route is part of the routing table.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list