Answer the question
In order to leave comments, you need to log in
How to configure the use of 2 IPs on a VPS?
Hello, there is a VPS connected to it by 2 IPs, there are interfaces for them:
venet0:0 and venet0:1 When I
connect
via ssh from IP1 and execute the command
wget -O - -q icanhazip.com
I see IP1
the same command, I see IP1 again. Since this interface is configured by default.
Is it possible to do something so that when connecting to the server via ssh over IP2, the interface corresponding to it is used to access the Internet?
Or maybe you can somehow set your default interface for each user? And then create a second user and connecting through the first one will I go out through IP1, and through the second one through IP2?
Can this be implemented? If yes, how, please tell me. I can't find anything clear by googling.
Answer the question
In order to leave comments, you need to log in
In the literal sense, what you want is impossible to do. the route table is global, but there is a way out how you can get a little fond of it and you will have to do the following:
1) There are keys in iptables –uid-owner –gid-owner –pid-owner. Through them, catch and mark traffic, respectively, each key catches by its type, the first by the user uid, the second by the user group guid and the third by the process pid, but with the 3rd one it’s not so simple. you will have to monitor the desired process somewhere with a script and grab the pid.
2) Further, according to the labeling of the packages, fuss into the desired interface.
It will work but get sexual relations for a couple of days if not weeks. in fact, you will have to duplicate all the rules in large numbers.
You seem to have OpenVZ. Ask the hoster or look in the control panel to change the main IP. When adding an IP, the first one will take precedence.
Indicate in the application which IP to use
. Alternatively, you can still configure it through IPtables, but this requires a long smoking, in general, the way for professionals who are willing to spend several days on the trial
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question