[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Selecting source ip

On May 28, 2003 05:02 pm, Stefan Neufeind wrote:

> when I request a file from a linux box using lynx the source ip of my
> request is the ip of eth0. But how can I change the source ip to
> other ips which are also bound to eth0 (via eth0:0 etc.)? Do I need
> to change the default gate from eth0 to eth0:0 for example? Isn't
> there a way to just change the source ip for all programs I will
> execute in my current environment / bash without affecting other
> programs / tasks?

As someone else already pointed not possible.  You can accomplish this on an 
app-by-app basis, examples:

- telnet and ssh option -b
- ping option -I
- wget option --bind-address

I don't know what you need this for but if you can use wget instead of lynx 
you might be all set ... I don't see a similar option for wget.

Alternatively, you could run a proxy (squid for example) and bind the proxy to 
the specific IP of your choice.  If you request webpages through that proxy I 
would expect it to use the chosen source IP in it's requests.  Most command 
line web clients will honour the http_proxy environment variable.

If you're concerned about more than just web clients you might be able to 
acheive the desired effect with advanced routing (see iproute package).

Hope that helps, if not let us know more about what you're trying to achieve.
Fraser Campbell <fraser@wehave.net>                 http://www.wehave.net/
Brampton, Ontario, Canada                                 Debian GNU/Linux

Reply to: