D
D
dailysse2018-05-01 18:45:35
Computer networks
dailysse, 2018-05-01 18:45:35

How to make requests on multiple ip?

Good day. There is a dedicated server and in addition to the main ip address there is an additional one. I need to make requests to various sites on the Internet so that I can choose from which ip address a given request will be made. How can I do that?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Danil Sapegin, 2018-05-01
@ynblpb_spb

I would solve this issue by installing a squid proxy on this computer. Set up the squid in such a way that when accessing 3128, requests from one IP leave, when accessing 3129 from the second IP.
In the application that requests, simply add the use of proxy 127.0.0.1:3128/3129

Y
Yaroslav, 2018-05-02
@yaror

It depends on what and how it should be)
Here is from man curl:

--interface
Perform an operation using a specified interface. You can enter interface name, IP address or host name. An example could look like:
curl --interface eth0:1 www.netscape.com
If this option is used several times, the last one will be used.

If you want to write a program that does this yourself, then you should refer to the documentation for implementing network sockets in a language close to you.
This is how a specific ip address is attached to a future TCP connection in C:
When a socket is created with socket(2), it exists in a name space
(address family) but has no address assigned to it. bind() assigns
the address specified by addr to the socket referred to by the file
descriptor sockfd. addrlen specifies the size, in bytes, of the
address structure pointed to by addr. Traditionally, this operation
is called “assigning a name to a socket”.

V
vreitech, 2018-05-01
@fzfx

in theory cgroups should help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question